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 07:58 PM, Joshua Haberman wrote:
> Andrew Haley <aph <at> redhat.com> writes:
>> but
>>
>> (union u*)&i
>>
>> is not a legal lvalue expression because the dereference is undefined
>> behaviour.
>
> Your example does not contain a dereference.
>
>> You may only dereference a pointer as permitted by 6.3.2.3.
>
> 6.3.2.3 does not mention dereferencing at all; it only addresses pointer
> conversion. Dereferencing is defined in 6.5.3.2.
>
> But let me ask you this. What do you think 6.5 paragraph 7 means? For
> example, are you also of the opinion that this is illegal?
>
> int i;
> unsigned int *pui = (unsigned int*)&i;
> unsigned int ui = *pui;
That's covered by 6.3.2.3 Para 2.
Andrew.