This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37569] Loop incorrectly optimized to endless loop with -Os/-O2/-O3
- From: "ppr at melexis dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Sep 2008 10:20:59 -0000
- Subject: [Bug c/37569] Loop incorrectly optimized to endless loop with -Os/-O2/-O3
- References: <bug-37569-16736@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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