Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Union type conversions Message-ID: <12490@mimsy.UUCP> Date: 15 Jul 88 03:00:56 GMT References: <5754@bloom-beacon.MIT.EDU> <1180@mcgill-vision.UUCP> <3714@ece-csc.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 20 >In article <19845@watmath.waterloo.edu> atbowler@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@ece-csc.UUCP> jnh@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@mimsy.umd.edu Path: uunet!mimsy!chris