This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Undefined behavior due to

On 2015-03-12 13:55:50 -0600, Martin Sebor wrote:
> On 03/12/2015 03:10 AM, Vincent Lefevre wrote:
> >Well, this depends on the interpretation of effective types in the
> >case of a union. For instance, when writing
> >
> >   union { char a[16]; int b; } u;
> >   u.b = 1;
> >
> >you don't set the member only (an int), but the whole union object is
> >affected, even bytes that are not parts of the int. So, one may see
> >the effective type as being the union type.
> The purpose of the term /effective type/ is to make it possible
> to talk about types of allocated objects (those with no declared
> type). In the example above, u.b is declared to have the type
> int and assigning to it doesn't change the type of other members
> of the union. But because u.a has a character type the value of
> u.b can be accessed via u.a (or any other lvalue of that type).

But if an object is declared with type T, the effective type of this
object is T, right? So, above, the effective type of u is the union
{ char a[16]; int b; } type.

Vincent Lefèvre <> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]