This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC aliasing rules: more aggressive than C99?
On 01/05/2010 02:09 AM, Joshua Haberman wrote:
> Erik Trulsson <ertr1013 <at> student.uu.se> writes:
>> On Mon, Jan 04, 2010 at 08:17:00PM +0000, Joshua Haberman wrote:
>>> The text you quoted does not contain any "shall not" language about
>>> dereferencing, so this conclusion does not follow.
>>
>> It doesn't have to use any "shall not" language. If the standard does not
>> say that any particular action is allowed or otherwise defines what it
>> does, then that action implicitly has undefined behaviour.
>
> Section 6.5 does define circumstances under which converted pointers may
> be dereferenced.
No. It says
"An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:
but
(union u*)&i
is not a legal lvalue expression because the dereference is undefined
behaviour. You may only dereference a pointer as permitted by 6.3.2.3.
Andrew.