[gclist] C++ proposal

Stefan Monnier stefan.monnier@lia.di.epfl.ch
Wed, 29 May 1996 11:41:53 +0200


> Yes and no, at least for C. The difference in the effect of operators
> on structs and unions in C is this: "[...] if a member of a union
> object is accessed after a value is stored in a different member of
> the object, the behaviour is implementation- defined." (ISO standard,
> section 6.3.2.3).

So, it's always safe to implement unions like structs.

> However, the standard also states: "A structure type
> describes a sequentially allocated nonempty set of member objects
> [....] A union type describes an overlapping nonempty set of member
> objects [....]" (section 6.1.2.5).

This is really only a hint to the implementor about what is usually meant,
but doesn't have to be enforced since the semantics are weak enough (see the
above paragraph) that a program can only tell the difference by relying on
implementation-defined behavior.


	Stefan