[cfe-dev] Clang 3.3 assertion failure for local extern declarations of variables with names matching function parameters

Tom Honermann thonermann at coverity.com
Mon Aug 5 20:25:31 PDT 2013


Clang 3.3, when compiled with assertions enabled, fails an assertion for 
the following test case.  I believe this code is ill-formed, but at 
least some versions of gcc accept this test case (I tested 4.6.3 and 
4.8.0).  Clang 3.2 accepts this test case as well.

I filed a bug report for the assertion failure [1], but thought it would 
be good to clarify expected behavior on the mailing list.

$ cat t.cpp
struct S;
void f(S *s) {
     extern S *s;
     s;
}

$ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ clang -c t.cpp
clang: llvm-3.3/tools/clang/lib/AST/Decl.cpp:932: void 
clang::NamedDecl::verifyLinkage() const: Assertion `!D || 
D->CachedLinkage == CachedLinkage' failed.

[1]: http://llvm.org/bugs/show_bug.cgi?id=16804

Tom.




More information about the cfe-dev mailing list