Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!uflorida!gatech!ncsuvx!ece-csc!jnh
From: jnh@ece-csc.UUCP (Joseph Nathan Hall)
Newsgroups: comp.lang.c
Subject: Re: Union type conversions
Message-ID: <3714@ece-csc.UUCP>
Date: 14 Jul 88 16:13:33 GMT
References: <5754@bloom-beacon.MIT.EDU> <1180@mcgill-vision.UUCP> <19845@watmath.waterloo.edu>
Reply-To: jnh@ece-csc.UUCP (Joseph Nathan Hall)
Organization: North Carolina State University, Raleigh, NC
Lines: 22

In article <19845@watmath.waterloo.edu> atbowler@watmath.waterloo.edu (Alan T. Bowler [SDG]) writes:
 Actually I dn't think you are guaranteed anything more than
 if you assign to a particular union member you can get back the
 value you assigned by naming that member provided that you do
 no assign to any other member.  It is usual practice for a compiler
 to put all members of a union at the same starting address
 (i.e. equivalence them) however, there is no guarantee that
 the compiler does not simply do the equivalent of
 #define union struct
 and proceed from there.  Using union for a "pun" operation
...

Sorry, you're just plain wrong here.  From page 140 of K&R, I quote:

	"In effect, a union is a structure in which all members have
	 OFFSET ZERO [emphasis added], the structure is big enough to hold
	 the 'widest' member, and the alignment is appropriate for all
	 of the types in the union ..."
-- 
v   v sssss|| joseph hall                      || 201-1D Hampton Lee Court
 v v s   s || jnh@ece-csc.ncsu.edu (Internet)  || Cary, NC  27511
  v   sss  || the opinions expressed herein are not necessarily those of my
-----------|| employer, north carolina state university . . . . . . . . . . .