This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is the GCC optimizer too smart?
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: sergio borghese <sergio dot borghese at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 10 Dec 2009 13:51:57 +0100
- Subject: Re: Is the GCC optimizer too smart?
- References: <2280d7230912100403k6bf05d01p4d719e89c1ed2b52@mail.gmail.com>
On 12/10/2009 01:03 PM, sergio borghese wrote:
> Now my question is: is it correct that the compiler enforces the
> constantness of the variable, even tought it states in the warning
> that the const qualifier has been discarded?
>
I think you are missing that the compiler is not "enforcing" anything,
just doing what it likes best depending on the circumstances, since you
are triggering an undefined behavior and anything can happen, in principle.
By the way, this kind of question is more suited for gcc-help.
Paolo.