Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!td From: td@alice.UUCP (Tom Duff) Newsgroups: net.lang.c Subject: Re: Re: Structure question (problem) Message-ID: <3772@alice.UUCP> Date: Thu, 30-May-85 12:09:26 EDT Article-I.D.: alice.3772 Posted: Thu May 30 12:09:26 1985 Date-Received: Fri, 31-May-85 03:59:34 EDT References: <10@ucbcad.UUCP> Organization: Bell Labs, Murray Hill Lines: 29 It is very difficult to formulate a reasonable rule for union initialization. The ANSI rule (initializers apply to the first member) is just a kludge. The `match the types' rule plays fast and loose with C's type-matching rules. Consider ucbcat!faustus's example (here simplified): union{ int a; long b; }c[]={ 57, (long)76365 }; ucbcat!faustus no doubt expects 57 to initialize a and 76365 to initialize b. But 57 is a legal initializer for b and (long)76365 is a legal initializer for a. So the `match the types' rule is not a simple patch to the language, but requires a completely different set of type-matching rules than already exist. This is, to say the least, unsatisfactory. Furthermore, this scheme cannot even be made to work. The following example should indicate one reason: union{ int a; struct{ int :16; int b; }c; }d={5};