This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48197] possible wrong code bug at -O0
- From: "regehr at cs dot utah.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 Mar 2011 20:15:04 +0000
- Subject: [Bug c/48197] possible wrong code bug at -O0
- Auto-submitted: auto-generated
- References: <bug-48197-4@http.gcc.gnu.org/bugzilla/>
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.