Re: [9fans] C compiler question

2009-07-15 Thread robert wilson
erik quanstrom wrote: assuming that pointers to incomplete types are themselves incomplete, and you haven't cited chapter and verse showing they are, i read that paragraph as saying that what plan 9 libraries do would be illegal, and therefore if we follow the standard, we'd need to remove

Re: [9fans] C compiler question

2009-07-15 Thread Ethan Grammatikidis
On Tue, 14 Jul 2009 12:45:56 -0700 Russ Cox r...@swtch.com wrote: enough. there was a bug, plain and simple. struct T { struct S s; }; is not valid. never was, never will be. fix the compiler already. Newbie question: Does this statement apply to any struct S (meaning you can

Re: [9fans] C compiler question

2009-07-15 Thread erik quanstrom
Newbie question: Does this statement apply to any struct S (meaning you can never have a struct as member of another struct), or does it only apply in cases where the structure of S is not known at that point? the latter. - erik

Re: [9fans] C compiler question

2009-07-14 Thread Adriano Verardo
erik quanstrom wrote: Yes, but in my example - sorry - NeverDefined doesn't mean declared and defined elsewhere (or not) but not declared .and. not defined. true enough. the patch i sent still rejects your construct. i'd still be interested to hear a perspective of someone with more

Re: [9fans] C compiler question

2009-07-14 Thread erik quanstrom
The point is how to compute the offset(s) of the last field at compile / run time. the offset of the last field is not in question. i believe you mean the size? 8c should reject not defined (named only) types, as *nix compilers do. yes. I prefer to have only the tricky but standard

Re: [9fans] C compiler question

2009-07-14 Thread Adriano Verardo
erik quanstrom wrote: The point is how to compute the offset(s) of the last field at compile / run time. the offset of the last field is not in question. i believe you mean the size? It's really the same info. struct { . // total sizeof = 100 int B[..]; }A;

Re: [9fans] C compiler question

2009-07-14 Thread erik quanstrom
erik quanstrom wrote: The point is how to compute the offset(s) of the last field at compile / run time. the offset of the last field is not in question. i believe you mean the size? It's really the same info. it is not. the size and offset are different things.

Re: [9fans] C compiler question

2009-07-14 Thread Roman V Shaposhnik
On Mon, 2009-07-13 at 23:14 -0400, erik quanstrom wrote: Yes, but in my example - sorry - NeverDefined doesn't mean declared and defined elsewhere (or not) but not declared .and. not defined. true enough. the patch i sent still rejects your construct. i'd still be interested to hear a

Re: [9fans] C compiler question

2009-07-14 Thread erik quanstrom
rejecting the struct seems like the right thing to do as per ISO/IEC 9899:1999 (http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf) sec. 6.7.2.1 para. 2 A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an

Re: [9fans] C compiler question

2009-07-14 Thread Roman V Shaposhnik
On Tue, 2009-07-14 at 13:46 -0400, erik quanstrom wrote: rejecting the struct seems like the right thing to do as per ISO/IEC 9899:1999 (http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf) sec. 6.7.2.1 para. 2 A structure or union shall not contain a member with incomplete or

Re: [9fans] C compiler question

2009-07-14 Thread erik quanstrom
For the dirty corner of any language one is usually better off with a written formal standard. Now, since Plan9 doesn't have such a document, relying on a work done by c99 committee would seem like a wise thing to do. And it is not like we are talking about C++ ISO standard here, the C99

Re: [9fans] C compiler question

2009-07-14 Thread Russ Cox
enough. there was a bug, plain and simple. struct T { struct S s; }; is not valid. never was, never will be. fix the compiler already. russ

Re: [9fans] C compiler question

2009-07-13 Thread Adriano Verardo
erik quanstrom wrote: 8c silently accept the above definition and sizeof(U) is 100. ??? The sources which include the definition of NeverDefined are regularly compiled too and sizeof(U) = 100 + sizeof(NeverDefined). i think the issue is that there isn't currently a distinction between

Re: [9fans] C compiler question

2009-07-13 Thread erik quanstrom
Yes, but in my example - sorry - NeverDefined doesn't mean declared and defined elsewhere (or not) but not declared .and. not defined. true enough. the patch i sent still rejects your construct. i'd still be interested to hear a perspective of someone with more experience with the c compiler.

Re: [9fans] C compiler question

2009-07-13 Thread Russ Cox
Yes, but in my example - sorry - NeverDefined doesn't mean declared and defined elsewhere (or not) but not declared .and. not defined. no and yes. union U { struct { struct NeverDefined nf; // Unknown, definition not #included } S1 }; declares a struct named

Re: [9fans] C compiler question

2009-07-12 Thread erik quanstrom
8c silently accept the above definition and sizeof(U) is 100. ??? The sources which include the definition of NeverDefined are regularly compiled too and sizeof(U) = 100 + sizeof(NeverDefined). i think the issue is that there isn't currently a distinction between this typedef

[9fans] C compiler question

2009-07-11 Thread Adriano Verardo
Hi, all. Yesterday I observed different sizeof() of a union in a library function and in the main program. The reason seems to be a forgotten #include in a library source. union U { struct { fields of defined types// sizeof = 100 struct NeverDefined nf;