Here&#x27;s an example indicating how we can use overflow from INT_MAX to INT_MIN to terminate a loop... ...if signed overflow would be properly defined.<p><pre><code>    &#x2F;* Write \&quot;hi\&quot; n times, counter will wrap to negative
     * to indicate we&#x27;ve written enough greetings.
     *
     * i=3  -&gt; we want to write hi three times
     *
     * 1st INT_MAX-i+1 = INT_MAX-2 -&gt; write hi
     * 2nd INT_MAX-1               -&gt; write hi
     * 3rd INT_MAX                 -&gt; write hi
     * 4th INT_MIN      (signed overflow, terminates loop)
     *&#x2F;

    int
    write_n_times_hi(int i)
    {
        int j;
        for (j=INT_MAX-i+1; j&gt;0; j++)
                printf(&quot;hi\n&quot;);
        return i;
    }
</code></pre>
This will be compiled into an endless loop by gcc 5.3.0&#x2F;x86_64 for -O3, but will terminate properly with -O0.<p>If you change the (undefined for j=INT_MAX)<p><pre><code>    j++
</code></pre>
into the (defined)<p><pre><code>    *((unsigned*)&amp;j)++,
</code></pre>
the compiler may no longer assume that j stays &gt;0 all of the time, and the loop has to terminate.