Article View: comp.std.c
Article #5062Re: Question about unions
From: Karl Heuer
Date: Fri, 27 May 1988 22:56
Date: Fri, 27 May 1988 22:56
15 lines
1284 bytes
1284 bytes
In article <16490002@hpcllz2.HP.COM> walter@hpcllz2.HP.COM (Walter Murray) writes:
>[The dpANS mentions that there may be padding at the end of a structure.]
>Is there any reason a similar statement is not made about unions?
>Section 3.3.3.4 (the sizeof operator) certainly implies that a
>union may have padding.
I don't agree that 3.3.3.4 implies it, but I think that it does have to be
allowed. The existence of pointers to incomplete types requires that a
word-addressible machine use a consistent format for pointer-to-union
(likewise for pointer-to-struct; this has been expressed as "all struct
pointers smell the same"), and I believe the usual choice for this is word
pointers -- which means that union{char} contains trailing padding. Looks
like 3.5.2.1 should be reworded to mention unions.
Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID:
<4278@haddock.ISC.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!necntc!ima!haddock!karlReferences:
<16490002@hpcllz2.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.std.c Subject: Re: Question about unions Message-ID: <4278@haddock.ISC.COM> Date: 27 May 88 22:56:33 GMT References: <16490002@hpcllz2.HP.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 14