[cfe-dev] [cfe-commits] r41592 - in /cfe/trunk: AST/ASTContext.cpp AST/Type.cpp CodeGen/CodeGenTypes.cpp Sema/SemaDecl.cpp include/clang/AST/ASTContext.h include/clang/AST/Type.h

Chris Lattner clattner at apple.com
Thu Aug 30 14:20:45 PDT 2007


On Aug 30, 2007, at 1:22 PM, Keith Bauer wrote:

>> Which missing extern?  This might be a clang bug still,
>
> Hmm, GCC's pretty insistent on accepting it:
>
> imac:Desktop keith$ cat missing_extern.c
> struct foo { int x; };
> struct foo f;
> struct foo f = { 3 };
> imac:Desktop keith$ gcc -fsyntax-only -Wall -Wextra missing_extern.c
> imac:Desktop keith$ clang -fsyntax-only missing_extern.c
> missing_extern.c:3:12: error: redefinition of 'f'
> struct foo f = { 3 };
>            ^
> missing_extern.c:2:12: error: previous definition is here
> struct foo f;
>            ^
> 2 diagnostics generated.
>
> OTOH, the only reason it was working for me was that only one source
> file included the header that was missing the extern... so whether
> it's a clang bug or not, it was my bug too ;)

Yep, this is a clang bug.  "struct foo f" should have common linkage,  
and be merged with the later full definition.  C is a great  
language ;-).   GCC should reject this with -fno-common.

-Chris 



More information about the cfe-dev mailing list