[Bug c/37569] Loop incorrectly optimized to endless loop with -Os/-O2/-O3
ppr at melexis dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 18 10:22:00 GMT 2008
------- Comment #9 from ppr at melexis dot com 2008-09-18 10:20 -------
(In reply to comment #8)
> I think this code is invalid. I seem to recall the argument that it's
> undefined behavior to increment or decrement a pointer to 0.
Well, the pointer is not NULL initially, it's just decremented until it reaches
zero. I agree this code doesn't make much sense in i686-pc environment, but
I've discovered the issue while working with GCC port for 16-bit
microcontroller. The routine is used to calculate ROM checksum and address 0 is
a perfectly valid address at this target.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37569
More information about the Gcc-bugs
mailing list