This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR3609
- To: gcc-patches at gcc dot gnu dot org, mark at codesourcery dot com
- Subject: Re: PR3609
- From: Jan Hubicka <jh at suse dot cz>
- Date: Thu, 9 Aug 2001 20:47:37 +0200
Hi,
the conclusion that I can access data past end of constant string
by knowing what compiler does looks wrong to me.
In my opinion the testcase shown in comment triggers undefined behaviour.
GCC is definitly allowed to arrange thinks in a way to make the memory
trap when accesing that place, as it is allowed to do any other undefined
efect IMO.
I think it would be shame to drop such optimizations just because some programs
are broken. This particular optimization is just special case, how compiler
can conclude the range of variable by seeing that it is used as index in
object of known size. This technique is very practical, for example to limit
amount of iteration given loop does.
Honza