[Bug c/48197] possible wrong code bug at -O0

regehr at cs dot utah.edu gcc-bugzilla@gcc.gnu.org
Fri Mar 18 20:20:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48197

--- Comment #5 from John Regehr <regehr at cs dot utah.edu> 2011-03-18 20:14:51 UTC ---
Here's a test case:

int printf(const char *format, ...);

int main (void)
{
  int y = 0x8000;
  int x1 = (long)0 > ((unsigned int)0 ^ (signed short)y);
  int x2 = (long)0 > ((unsigned int)0 ^ (signed short)((int)0x8000));
  int x3 = (long)0 > ((unsigned int)0 ^ (signed short)0x8000);
  int x4 = (long)0 > ((unsigned)0 ^ (unsigned)y);
  int x5 = (long)0 > ((unsigned)0 ^ (unsigned)32768);
  int x6 = (long)0 > (unsigned)32768;
  int x7 = (long)0 > (long)32768;
  int x8 = 0;

  printf("%d %d %d %d %d %d %d %d\n",
         x1, x2, x3, x4, x5, x6, x7, x8);

  return 0;
}

And here's the output:

[regehr@gamow ~]$ current-gcc -O0 small.c -o small -Wall
[regehr@gamow ~]$ ./small 
1 0 0 0 0 0 0 0

I think 0 should be assigned into all of x1..x8.



More information about the Gcc-bugs mailing list