Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Charles Forsyth
yes, how true. On Tue, 2 Apr 2019 at 18:22, Devon H. O'Dell wrote: > Also worth noting that any padding bits are zeroed as well for > aggregate and union types. Not just setting all pointer values to NULL > and arithmetic types to positive or unsigned zero. > > Op di 2 apr. 2019 om 08:17

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-02 Thread Charles Forsyth
covered and covered1 On Tue, 2 Apr 2019 at 17:26, Anthony Martin wrote: > Charles Forsyth once said: > > I didn't look at the code closely enough earlier, but remembered > something > > from years ago this morning. It's a bug. It isn't platform specific. > > There is an existing fix in 9front

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-02 Thread Anthony Martin
Charles Forsyth once said: > I didn't look at the code closely enough earlier, but remembered something > from years ago this morning. It's a bug. It isn't platform specific. > There is an existing fix in 9front (I think it came from there) but it's > horrible. Still, better a horrible fix than

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Devon H. O'Dell
Also worth noting that any padding bits are zeroed as well for aggregate and union types. Not just setting all pointer values to NULL and arithmetic types to positive or unsigned zero. Op di 2 apr. 2019 om 08:17 schreef Skip Tavakkolian : > > like this: > > #include > #include > > struct option

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Kyohei Kadota
I see, I understand. thank you, Skip, Charles. 2019年4月3日(水) 0:06 Charles Forsyth : > > >> What is "be initialized implicitly the same as objects that have >> static storage duration" mean? > > > It refers back to the second part of case 10 of that section. > > On Tue, 2 Apr 2019 at 15:53, Kyohei

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Skip Tavakkolian
like this: #include #include struct option { int n; char *s; int flags; }; int main(void) { struct option opt = { 1, "test" }; static struct option opt2; printf("%d %s %x\n", opt.n, opt.s, opt.flags); printf("%x\n", opt2.flags); return 0; } On Tue, Apr 2, 2019 at 8:02 AM Skip Tavakkolian

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Charles Forsyth
> What is "be initialized implicitly the same as objects that have > static storage duration" mean? It refers back to the second part of case 10 of that section. On Tue, 2 Apr 2019 at 15:53, Kyohei Kadota wrote: > Thank you for a reply. > > I read spec on

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Skip Tavakkolian
I interpret it as: initialize it like a static variable. On Tue, Apr 2, 2019 at 7:53 AM Kyohei Kadota wrote: > Thank you for a reply. > > I read spec on http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf > then I'm confusing. > This spec describes Initialization: > > > 6.7.8

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Kyohei Kadota
Thank you for a reply. I read spec on http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf then I'm confusing. This spec describes Initialization: > 6.7.8 Initialization, p127 > > 19 The initialization shall occur in initializer list order, each initializer > provided for a > particular

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-02 Thread Kyohei Kadota
I ran this code on 386 machine on QEMU based public VPC service. 2019年4月2日(火) 9:27 Skip Tavakkolian : > > It should initialize to zero. 8c and 5c both do the right thing here. > > Which distribution and cputype? > > On Mon, Apr 1, 2019, 8:34 AM Kyohei Kadota wrote: >> >> Hi, 9fans. I use

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-02 Thread Charles Forsyth
> > In the present case, this appears to be a compiler bug. The aforementioned > reference to n1548 sec 6.7.9 para 10 is incorrect in that there _is_ an > explicit initializer here. The relevant text in the standard is sec 6.7.9 > pp 16-21, which specifies that in the event that an explicit

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-02 Thread David du Colombier
All the 9legacy patches are available on http://9legacy.org/patch.html. Most of the compiler changes consist in keeping them in sync with Charles' updates, available on https://bitbucket.org/plan9-from-bell-labs/plan9. The (partial) C99 changes were done long ago, in March 2006 and before.

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Skip Tavakkolian
what I have in /sys/src/cmd/cc here is identical to what's on 9p.io. On Mon, Apr 1, 2019 at 7:23 PM Kurt H Maier wrote: > On Mon, Apr 01, 2019 at 09:20:43PM -0400, Dan Cross wrote: > > On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier wrote: > > > > > On Mon, Apr 01, 2019 at 08:26:30PM -0400, Jeremy

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Kurt H Maier
On Mon, Apr 01, 2019 at 09:20:43PM -0400, Dan Cross wrote: > On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier wrote: > > > 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

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Dan Cross
On Mon, Apr 1, 2019 at 8:36 PM Kurt H Maier wrote: > 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

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Charles Forsyth
Yes, that's normal C behaviour. Only external and static storage is guaranteed to be zero. In a modern environment it seems a little mean, especially since you gave opt a partial initial value, but there are no half-measures in C. On Tue, 2 Apr 2019 at 01:27, Jeremy O'Brien wrote: > On Mon, Apr

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a?struct?

2019-04-01 Thread Kurt H Maier
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

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Jeremy O'Brien
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

Re: [9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Skip Tavakkolian
It should initialize to zero. 8c and 5c both do the right thing here. Which distribution and cputype? On Mon, Apr 1, 2019, 8:34 AM 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

[9fans] Don't Plan 9 C compiler initialize the rest of member of a struct?

2019-04-01 Thread Kyohei Kadota
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"};