Package: clang-3.3 Version: 1:3.3-9 Severity: normal Dear Maintainer,
I was writing a class where I wanted to do something similar to this: class Foo { class Bar { Foo::Qux get_qux(); }; class Qux { }; }; And clang (rightly) complains that get_qux can't be declared at that position because there's no type named Foo:Qux yet. So I figured, in my tired and incoherent state, let's just try adding the class keyword so clang knows it's an incomplete type: class Foo { class Bar { class Foo::Qux get_qux(); }; class Qux { }; }; This, as it happens, crashes clang. It probably shouldn't do that, even though it's not valid C++. Interestingly, I still get the correct error message out of clang before it crashes. Here's the complete output from clang as it crashes: foo.cpp:3:14: error: no class named 'Qux' in 'Foo' class Foo::Qux get_qux(); ~~~~~^ 0 libLLVM-3.3.so.1 0x00007f6154856652 llvm::sys::PrintStackTrace(_IO_FILE*) + 34 1 libLLVM-3.3.so.1 0x00007f61548564b9 2 libpthread.so.0 0x00007f615382f210 3 clang 0x0000000000c09ad0 4 clang 0x0000000000c0cfde clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*) + 190 5 clang 0x00000000009fabff clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) + 831 6 clang 0x0000000000a440dd clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Expr*, clang::VirtSpecifiers const&, clang::InClassInitStyle) + 861 7 clang 0x00000000008f54cb clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) + 5467 8 clang 0x00000000008f6ad9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) + 1961 9 clang 0x00000000008f8415 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) + 3685 10 clang 0x00000000008e57bf clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 4047 11 clang 0x00000000008f446b clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject*) + 1275 12 clang 0x00000000008f6ad9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) + 1961 13 clang 0x00000000008f8415 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) + 3685 14 clang 0x00000000008e57bf clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 4047 15 clang 0x00000000008cfa74 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 84 16 clang 0x00000000008d02ee clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 926 17 clang 0x00000000008d38a9 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 249 18 clang 0x00000000008d3ed2 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 194 19 clang 0x00000000008cc440 clang::ParseAST(clang::Sema&, bool, bool) + 352 20 clang 0x000000000063d129 clang::FrontendAction::Execute() + 169 21 clang 0x000000000061eb22 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 290 22 clang 0x000000000060a997 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1575 23 clang 0x0000000000605db8 cc1_main(char const**, char const**, char const*, void*) + 1160 24 clang 0x0000000000604847 main + 7847 25 libc.so.6 0x00007f6152872995 __libc_start_main + 245 26 clang 0x0000000000604e05 Stack dump: 0. Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.23.52.20130828 -resource-dir /usr/bin/../lib/clang/3.3 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.3/include -internal-isystem /usr/include/clang/3.3/include/ -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include/x86_64-linux-g! nu -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/jblake -ferror-limit 19 -fmessage-length 159 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/foo-cVZXYa.o -x c++ foo.cpp 1. foo.cpp:3:27: current parser token ';' 2. foo.cpp:1:1: parsing struct/union/class body 'Foo' 3. foo.cpp:2:2: parsing struct/union/class body 'Bar' clang: error: unable to execute command: Segmentation fault clang: error: clang frontend command failed due to signal (use -v to see invocation) Debian clang version 3.3-9 (branches/release_33) (based on LLVM 3.3) Target: x86_64-pc-linux-gnu Thread model: posix clang: note: diagnostic msg: PLEASE submit a bug report to http://bugs.debian.org/ and include the crash backtrace, preprocessed source, and associated run script. clang: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/foo-1Vw0aR.cpp clang: note: diagnostic msg: /tmp/foo-1Vw0aR.sh clang: note: diagnostic msg: ******************** I've attached the relevant files (foo.cpp, /tmp/foo-1Vw0aR.cpp, /tmp/foo-1Vw0aR.sh) to this report. The command I ran was simply: clang++ foo.cpp Please let me know if there's anything further I can do to assist. Thanks for your time, -Jules -- System Information: Debian Release: jessie/sid APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'oldstable-updates'), (500, 'oldstable-proposed-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.2.0-4-rt-amd64 (SMP w/4 CPU cores; PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages clang-3.3 depends on: ii libc6 2.17-93 ii libclang-common-3.3-dev 1:3.3-9 ii libclang1-3.3 1:3.3-9 ii libffi6 3.0.13-4 ii libgcc-4.8-dev 4.8.1-10 ii libgcc1 1:4.8.1-10 ii libllvm3.3 1:3.3-9 ii libobjc-4.8-dev 4.8.1-10 ii libstdc++-4.8-dev 4.8.1-10 ii libstdc++6 4.8.1-10 Versions of packages clang-3.3 recommends: ii llvm-3.3-dev 1:3.3-9 ii python 2.7.5-5 clang-3.3 suggests no packages. -- no debconf information
class Foo { class Bar { class Foo::Qux get_qux(); }; class Qux { }; };
# 1 "foo.cpp" 1 class Foo { class Bar { class Foo::Qux get_qux(); }; class Qux { }; };
/usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.23.52.20130828 -fdeprecated-macro -ferror-limit 19 -fmessage-length 159 -mstackrealign -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -x c++ foo-1Vw0aR.cpp