On Sat, 01 Jun 2013 22:12:51 +0100, Andrew Haley wrote: > In both cases you cannot actually use the memory at *p. I think gcc is > detecting the indexing but not the access.
That makes sense! On Sat, 1 Jun 2013 23:19:45 +0200, Jakub Jelinek wrote: > It is not a bug, the warning isn't guaranteed to report all such cases of > undefined behavior, and due to lack of infrastructure in GCC 4.8 can't be > reported if certain passes discover the undefined behavior. > GCC 4.9 warns on both of the bad loops, but even in 4.9, if the loop > doesn't have constant bounds or has multiple exits etc., GCC will not warn > and just might optimize based on the fact that undefined behavior doesn't > happen in correct code. Lack of warning doesn't mean code is bug free. ...If that was the case, I'd just turn all warnings off. ;) Thank you both, for the excellent answers. =) Love Jens