Union type conversions
Chris Torek
chris at mimsy.UUCP
Fri Jul 15 13:00:56 AEST 1988
>In article <19845 at watmath.waterloo.edu> atbowler at watmath.waterloo.edu
>>(Alan T. Bowler [SDG]) writes:
>>... there is no guarantee that the compiler does not simply do the
>>equivalent of `#define union struct' ...
In article <3714 at ece-csc.UUCP> jnh at ece-csc.UUCP (Joseph Nathan Hall) writes:
>Sorry, you're just plain wrong here. From page 140 of K&R, I quote:
... from the *de*scriptive part of the text, which says only that
> "In effect, a union is a structure in which all members have
> OFFSET ZERO [emphasis added] ..."
The point of this quote is to warn users that writing on any one
element of a union *may* stomp any other element, not that it *must*
stomp other elements. Alan Bowler is right; unions make few
guarantees. On the other hand, a compiler that does not conserve
storage with union definitions is probably not worth using.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list