This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 4.8.1: -O2 warnings one element off
- From: Jens Bauer <jens-lists at gpio dot dk>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 1 Jun 2013 23:30:22 +0200
- Subject: Re: gcc 4.8.1: -O2 warnings one element off
- References: <20130601230821231127 dot ebd41391 at gpio dot dk> <51AA63D3 dot 6030306 at redhat dot com>
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