How undefined signed overflow enables optimizations in GCC
EDIT: I see- a different reading of the post than my original take would suggest that the author is saying, you as a C&#x2F;C++ programmer are &quot;not allowed&quot; to compile code that would cause under&#x2F;overflow. The compiler assumes that you are following this rule, enabling these optimizations. The author&#x27;s wording is unclear as to who or what is not being allowed to under&#x2F;overflow, hence my confusion.<p>---<p>Right off the bat-<p>&gt; Signed integers are not allowed to wrap in C and C++<p>What? This is...not true.<p><pre><code>  $ cat &gt; test.c
  #include &lt;stdio.h&gt;
  #include &lt;limits.h&gt;
  
  int main()
  {
      int i = INT_MAX;
      printf(&quot;%i\n%i\n&quot;, i, i+1);
  }
  
  $ cc test.c 
  $ .&#x2F;a.out 
  2147483647
  -2147483648
</code></pre>
Im not an expert on these matters, but I suspect signed integers are <i>not defined as wrapping</i> and in fact not defined as doing anything particular in under&#x2F;overflow situations, though in one common convention, two&#x27;s complement integer arithmetic, they often do. The optimizations rely on the fact that the programmer can&#x27;t depend on any specific overflow or underflow behavior.