🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2790

Re: Bitfields in unions

#2790
From: Eamonn McManus
Date: Mon, 22 Apr 1991 18:47
31 lines
1531 bytes
gvr@cs.brown.edu (George V. Reilly) writes:
>+ 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.

As I mentioned in my original message, K&R2 also seems to imply
obliquely that unions may not contain bitfields.  Section A8.3:

    ...

    A struct-declaration-list is a sequence of declarations for the
    members of the structure or union:

    ...

    Usually, a struct-declarator is just a declarator for a member of a
    structure or union.  A structure member may also consist of a
    specified numbers of bits.  Such a member is also called a
    /bit-field/, or merely /field/; its length is set off from the
    declarator for the field name by a colon.

	struct-declarator:
	    declarator
	    declarator[opt] : constant-expression

Although the grammar allows union bitfields, the text by saying `A
*structure* member may also...' seems to be excluding unions.  It should
say `A structure or union member...' or just `Such a member...'.

,
Eamonn
Technical Details
Message-ID: <orange@dce.ie>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!tcdcs!dce.ie!em
References: <carbide@dce.ie> <680@taumet.com> <72969@brunix.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!tcdcs!dce.ie!em
From: em@dce.ie (Eamonn McManus)
Newsgroups: comp.std.c
Subject: Re: Bitfields in unions
Message-ID: <orange@dce.ie>
Date: 22 Apr 91 18:47:15 GMT
References: <carbide@dce.ie> <680@taumet.com> <72969@brunix.UUCP>
Organization: Datacode Communications Ltd, Dublin, Ireland
Lines: 31