Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!think!mintaka!bloom-beacon!shelby!mcnc!thorin!unc!alexande From: alexande@unc.cs.unc.edu (Geoffrey D. Alexander) Newsgroups: gnu.gcc.bug Subject: Re: bug in gcc-1.36 structure initialization . Message-ID: <11551@thorin.cs.unc.edu> Date: 20 Jan 90 18:21:08 GMT References: <9001170733.AA09095@life.ai.mit.edu> <11506@thorin.cs.unc.edu> Sender: news@thorin.cs.unc.edu Reply-To: alexande@unc.cs.unc.edu (Geoffrey D. Alexander) Distribution: gnu Organization: University Of North Carolina, Chapel Hill Lines: 25 In article <11506@thorin.cs.unc.edu> I write: >K&R, 2nd edition states the following in section A8.7 (bottom of page 219): > > The initializer for a union is either a single expression of the same > type, or a brace-enclosed initializer for the first member of the union. > >Note that MyStruct has one member of type MyUnion. Since type MyUnion is a >union, it must either be initialize by an expression of type MyUnion or an >brace_enclosed initializer for the first member of the union which has type >char*. I assume you wish to initialize abc.name to 0. To do this, you must >have two set of braces: > > MyStruct abc = { {0} } > >This compiles without error under gcc 1.36 on a Sun-3M60 running SunOS 4.0.3. >I don't believe the problem you reported is a bug. > >Geoff Alexander If have been informed, although K&R 2ed doesn't mention it, that the ANSI standard allows the inner set of braces to be dropped in this case. The problem reported is actually a bug. However, the work-around is to use two sets of braces until there is a fix. Geoff Alexander