From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 1 Apr 2019 17:35:32 -0700 From: Kurt H Maier To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20190402003532.GA55021@wopr> References: <43a5572d-ea50-41a8-9897-9900f13c5a00@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43a5572d-ea50-41a8-9897-9900f13c5a00@www.fastmail.com> Subject: Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct? Topicbox-Message-UUID: f7ce7bb8-ead9-11e9-9d60-3106f5b1d025 On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy O'Brien wrote: > On Mon, Apr 1, 2019, at 11:33, Kyohei Kadota wrote: > > Hi, 9fans. I use 9legacy. > > > > About below program, I expected that flags field will initialize to > > zero but the value of flags was a garbage, ex, "f8f7". > > Is this expected? > > > > ``` > > #include > > > > struct option { > > int n; > > char *s; > > int flags; > > }; > > > > int > > main(void) > > { > > struct option opt = {1, "test"}; > > printf("%d %s %x\n", opt.n, opt.s, opt.flags); > > return 0; > > } > > ``` > > > > > > According to C99: "If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate." > > Stack variable == automatic storage duration. This appears to be correct behavior to me. > Can anyone provide the patches 9legacy uses to implement C99 compliance? Thanks in advance, khm