This is the mail archive of the gcc-patches@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]

Re: PR3609


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


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