Quote Originally Posted by flp1969 View Post
Code:
#include <stdio.h>

int main ( void )
{
  unsigned int a; 
  unsigned int b;
  unsigned int c;

  c = 0;
  for ( a = 0; a < 10; a++ ) 
    for ( b = 0; b < 2; b++ ) 
    {
      c++; 
           
      printf( "a=%u, c=%u\n", a, c );

      if ( c < a ) 
        return 123; 
    }

  return 0; 
}
On GCC 9+ this code will print on 3 lines and return 123 if you compile with any optimization options (any of -O options, except, of course -O0). As you can see there is no overflow and c will never be less than a. It should print 20 lines and return 0.

Change the comparison to b < N, where N != 2, in the inner loop and will work correctly. Or change the variables to 'int' (signed) and will work correctly.

This bug isn't present on GCC 8 and below.
I am running gcc version 10.2.1, on Debian testing, and -O1, -O2, and -O3, as well as with no -O options, all with -std=c18, and the code runs as you expect it should, and all return 0.

I cannot comment on this any further.