------- Comment #7 from edwintorok at gmail dot com  2009-04-25 14:18 -------
(In reply to comment #5)
> > > "An object shall have its stored value accessed only by an lvalue 
> > > expression
> > > that has one of the following types:
> > > 
> > >     * a type compatible with the effective type of the object,
> > >     * a qualified version of a type compatible with the effective type of 
> > > the
> > > object,
> > >     * a type that is the signed or unsigned type corresponding to the 
> > > effective
> > > type of the object,
> > >     * a type that is the signed or unsigned type corresponding to a 
> > > qualified
> > > version of the effective type of the object,
> > >     * an aggregate or union type that includes one of the aforementioned 
> > > types
> > > among its members (including, recursively, a member of a subaggregate or
> > > contained union), or
> > >     * a character type."
> > > 
> > > I'm casting to a union that has both types as members, why doesn't that 
> > > fit
> > > under the 5th case in the above quote?
> > 
> > Because it is certainly backwards.
> 
> Or rather, this refers to a compatible type to the type that was used
> to store the value, so it doesn't apply to type-punning.
> 

Yes, the union has a compatibly type to the one used to store the value (it has
a char member), hence the union can be used to access the value. I use a
different member to access the value, but isn't that what unions are for? :)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39895

Reply via email to