Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Tek) 9/26/83; site tekecs.UUCP Path: utzoo!linus!decvax!tektronix!orca!tekecs!joemu From: joemu@tekecs.UUCP (Joe Mueller) Newsgroups: net.lang.c Subject: Re: Notes on the ANSI standard Message-ID: <4139@tekecs.UUCP> Date: Mon, 29-Oct-84 17:13:29 EST Article-I.D.: tekecs.4139 Posted: Mon Oct 29 17:13:29 1984 Date-Received: Thu, 1-Nov-84 02:27:13 EST References: <553@asgb.UUCP> Organization: Tektronix, Wilsonville OR Lines: 27 > (2) > Section 4.1.3 states: > > "With one exception, a member of a union object may not be > inspected unless the value of the object has been assigned > using that same member." > > HOLY !! Whatever happened to overlaying values of differing > types? One of the more handy uses of unions is overlaying bitfields > with an integer so that the bits can be twiddled individually, but the > integer can be used for block operations on all the bits. I've also > used similar techniques for decoding bit fields of devices like a > Summagraphic Bitpad, or several mouses. > > I will grant that this is not good practice for writing portable code. > But to have these practices forbidden or enforced by the compiler is > totally unreasonable, especially for a systems implementation > language! (In implementation, enforcing this restriction seems > pretty cumbersome.) The problem with overlaying values of differing types to twiddle bits is that the twiddling is VERY implementation dependent. The intent of the committee is that the use of such practice should be discourageed and the result of such operation is UNDEFINED. I shall take it up with the committee to put words to that effect in the standard so that it is not expessly forbidden.