[gclist] Re: gclist-digest V1 #61

Fergus Henderson fjh@cs.mu.OZ.AU
Sun, 2 Jun 1996 17:53:18 +1000 (EST)


Robert A Duff, you wrote:
> 
> "Stefan Monnier" <stefan.monnier@lia.di.epfl.ch> says:
> 
> > So, it's always safe to implement unions like structs.
> 
> I believe it's always correct as far the ANSI C standard is concerned,
> and the C++ standard (if such ever exists), but it might break some
> people's programs.  Sigh.

No, that's not correct.   It is not possible for an implementation
which conforms to either the ANSI/ISO C standard or the draft ANSI/ISO C++
standard to implement unions like structs.

D. Hugh Redelmeier already posted the appropriate
quote from the ANSI C standard:

| section 3.5.2.1 (with the pre-ISO section numbers):
| 
| 	A pointer to a union object, suitably converted, points to each of
| 	its members (or if a member is a bit-field, then to the unit in
| 	which it resides), and vice versa.

The draft C++ standard also contains wording which implies the same thing.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.