This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 01/14/16 16:57, Joseph Myers wrote:
On Thu, 14 Jan 2016, Prathamesh Kulkarni wrote:
g++ rejects it during parsing. I tried similarly in C FE by adding a check for decl with incomplete struct/union type in finish_decl(), however that fails to compile the following case: typedef struct foo foo_t; foo_t x; struct foo { int i; }; g++ rejects the above case as well but gcc accepts it. Do C and C++ standards differ in this regard ?I don't know about C++, but this sort of thing is valid C if the type is complete at the end of the translation unit or is an incomplete array type (but not in the case where the variable is static - such a case with static, if supported, is an extension).
It's ill-formed C++.7.1.1/8 allows you to use a declared but undefined struct with 'extern', but not without it.
'The name of a declared but undefined class can be used in an extern declaration. Such a declaration can only be used in ways that do not require a complete class type'
(Although it doesn't seem to explicitly say that such a name can be used without an 'extern', the implication is that it cannot).
nathan
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |