🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2779

Re: Bitfields in unions

#2779
From: George V. Reilly
Date: Sun, 21 Apr 1991 18:45
18 lines
1301 bytes
In article <680@taumet.com> steve@taumet.com (Stephen Clamage) writes:
+ em@dce.ie (Eamonn McManus) writes:
+ 
+ >Can a union contain a bitfield?  K&R2 obliquely implies no, while
+ >gcc -pedantic says yes.  I'm inclined to believe K&R myself, though
+ >at least on machines without alignment constraints such a thing
+ >would seem reasonable.
+ 
+ The ANSI C standard says explicitly that a union may contain a bitfield.

Well, that's another thing that Harbison & Steele III have got wrong,
then.  On p. 128, it says:
	The syntax for defining components [in unions] is the same
	as that used for structures, except that bit fields are
	not permitted in unions.
________________
George V. Reilly   `Strike breaker'	gvr@cs.brown.edu   +1 (401) 863-7684
uunet!brunix!gvr   gvr@browncs.bitnet	Box 1910, Brown U, Prov, RI 02912
Technical Details
Message-ID: <72969@brunix.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!brunix!gvr
References: <carbide@dce.ie> <680@taumet.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!brunix!gvr
From: gvr@cs.brown.edu (George V. Reilly)
Newsgroups: comp.std.c
Subject: Re: Bitfields in unions
Message-ID: <72969@brunix.UUCP>
Date: 21 Apr 91 18:45:39 GMT
References: <carbide@dce.ie> <680@taumet.com>
Sender: news@brunix.UUCP
Reply-To: gvr@cs.brown.edu (George V. Reilly)
Organization: Dept. of Computer Science, Brown University, Providence RI
Lines: 18