GCC generates incorrect code when optimising

Richard Mitton richard.mitton@bigfoot.com
Tue Aug 15 17:58:00 GMT 2000


Attached is a file demonstrating this.
I've tried to simplify this as much as possible. As far as I can tell, it's
a compiler bug and not something wrong with my program.

The first command in main() should read a value from a function, add 1, and
print it. This should always result in 11 as the function always returns 10.
But if -O and -fomit-frame-pointer are enabled, it throws away the return
value and prints an incorrect answer.

The annoying thing is, there's some other code after this bit that
technically should have no effect, but if I remove it the bug goes away...

Any ideas guys? :-|
-----------------------------------------------
Richard Mitton,
richard.mitton@bigfoot.com
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-c
Size: 1341 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000815/0a530f90/attachment.bin>


More information about the Gcc-bugs mailing list