[Bug middle-end/28042] optimizer (-O2) changes the semantics of my programs

2006-06-16 Thread tonyg-gccbugzilla at lshift dot net


--- Comment #2 from tonyg-gccbugzilla at lshift dot net  2006-06-16 09:07 
---
Created an attachment (id=11678)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11678&action=view)
Test case (cleaned for -Wall) from Wolfgang's page

Identical (and still failing) test case to that given by Wolfgang Helbig, but
for changes I made to make it compile clean (and still fail) with -Wall:
rearranged procedures to avoid missing-prototype warning; fill in prototype for
main; return value from main; header files.


-- 


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



[Bug middle-end/28042] optimizer (-O2) changes the semantics of my programs

2006-06-16 Thread tonyg-gccbugzilla at lshift dot net


--- Comment #3 from tonyg-gccbugzilla at lshift dot net  2006-06-16 09:07 
---
Jun 16 10:07:17 [EMAIL PROTECTED]
~$ gcc -Wall -O0 -o is_small is_small.c

Jun 16 10:07:29 [EMAIL PROTECTED]
~$ ./is_small 
0

Jun 16 10:07:32 [EMAIL PROTECTED]
~$ gcc -Wall -O1 -o is_small is_small.c

Jun 16 10:07:37 [EMAIL PROTECTED]
~$ ./is_small 
ivalue: 1073741824
1

Jun 16 10:07:38 [EMAIL PROTECTED]
~$ gcc --version
gcc (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 


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



[Bug middle-end/28042] optimizer (-O2) changes the semantics of my programs

2006-06-16 Thread tonyg-gccbugzilla at lshift dot net


--- Comment #4 from tonyg-gccbugzilla at lshift dot net  2006-06-16 09:28 
---
Even better, if you remove the redundant parens, so that the program reads 

...
if ((integerValue >= 0)
&& (integerValue >= -1073741824) && (integerValue < 1073741824)) {
...


then the optimizer generates code correctly! (How on earth can paren placement
affect code generation???)


-- 


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