This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/37569] Loop incorrectly optimized to endless loop with -Os/-O2/-O3



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]