This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Clarification on Gcc's strict aliasing rules
Andrew Haley <aph@redhat.com> writes:
> On 11/12/2010 02:55 PM, Francis Moreau wrote:
>> "Segher Boessenkool" <segher@kernel.crashing.org> writes:
>>
>> [...]
>
>>
>>>>
>>>> Looking again at the second example:
>>>>
>>>> int f() {
>>>> union a_union t;
>>>> int* ip;
>>>> t.d = 3.0;
>>>> ip = &t.i;
>>>> return *ip;
>>>> }
>>>>
>>>> could you tell me what the effective type of 't.i' object ?
>>>
>>> int, if you can say that object exists at all: it does not have a stored
>>> value. The stored value of t is a double with value 3.0 . You can
>>> take its address and access it via that as "double" (or "char"), or you
>>> can access it as the union it is. You can not access it as "int".
>>>
>>
>> BTW, does your reasoning rely on the C standard ?
>
> It's a gcc extension. 5.25, Cast to a Union Type
How can it be related with the existence of an union member ?
--
Francis