[llvm-bugs] [Bug 32695] New: clang crashes with static const template class member

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 18 02:01:34 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32695

            Bug ID: 32695
           Summary: clang crashes with static const template class member
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hannes.mezger at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

With the attached sample, clang crashes when compiling main.cpp. Reason
is a different 'const' modifier on definition and declaration of the
static class member 'm'.

version info:

clang version 3.8.1-18 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-3.8/bin

clang output:

#0 0x00007f821d518765 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/llvm-3.8/bin/../lib/libLLVM-3.8.so.1+0x61a765)
#1 0x00007f821d516a46 llvm::sys::RunSignalHandlers()
(/usr/lib/llvm-3.8/bin/../lib/libLLVM-3.8.so.1+0x618a46)
#2 0x00007f821d516b83
(/usr/lib/llvm-3.8/bin/../lib/libLLVM-3.8.so.1+0x618b83)
#3 0x00007f821c2f6040 (/lib/x86_64-linux-gnu/libc.so.6+0x33040)
#4 0x00005581c480e90a (/usr/lib/llvm-3.8/bin/clang+0x10e690a)
#5 0x00005581c4815e59 (/usr/lib/llvm-3.8/bin/clang+0x10ede59)
#6 0x00005581c48183cc
clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind,
long, llvm::StringRef, llvm::StringRef,
llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>
> , llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>)
(/usr/lib/llvm-3.8/bin/clang+0x10f03cc)
#7 0x00005581c3af5945 clang::Diagnostic::FormatDiagnostic(char const*,
char const*, llvm::SmallVectorImpl<char>&) const
(/usr/lib/llvm-3.8/bin/clang+0x3cd945)
#8 0x00005581c3e1528b
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&) (/usr/lib/llvm-3.8/bin/clang+0x6ed28b)
#9 0x00005581c3af7ae0
clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&,
clang::DiagnosticIDs::Level) const (/usr/lib/llvm-3.8/bin/clang+0x3cfae0)
#10 0x00005581c3af7cc2
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const
(/usr/lib/llvm-3.8/bin/clang+0x3cfcc2)
#11 0x00005581c3af1284
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)
(/usr/lib/llvm-3.8/bin/clang+0x3c9284)
#12 0x00005581c4108bfa clang::Sema::EmitCurrentDiagnostic(unsigned int)
(/usr/lib/llvm-3.8/bin/clang+0x9e0bfa)
#13 0x00005581c418fa1b (/usr/lib/llvm-3.8/bin/clang+0xa67a1b)
#14 0x00005581c41962e5 clang::Sema::MergeVarDeclTypes(clang::VarDecl*,
clang::VarDecl*, bool) (/usr/lib/llvm-3.8/bin/clang+0xa6e2e5)
#15 0x00005581c41b4080 clang::Sema::MergeVarDecl(clang::VarDecl*,
clang::LookupResult&) (/usr/lib/llvm-3.8/bin/clang+0xa8c080)
#16 0x00005581c41b4ea6
clang::Sema::CheckVariableDeclaration(clang::VarDecl*,
clang::LookupResult&) (/usr/lib/llvm-3.8/bin/clang+0xa8cea6)
#17 0x00005581c41b9558
clang::Sema::ActOnVariableDeclarator(clang::Scope*, clang::Declarator&,
clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&,
llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&)
(/usr/lib/llvm-3.8/bin/clang+0xa91558)
#18 0x00005581c41cf686 clang::Sema::HandleDeclarator(clang::Scope*,
clang::Declarator&,
llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/usr/lib/llvm-3.8/bin/clang+0xaa7686)
#19 0x00005581c4412b4a
clang::Sema::ActOnTemplateDeclarator(clang::Scope*,
llvm::MutableArrayRef<clang::TemplateParameterList*>,
clang::Declarator&) (/usr/lib/llvm-3.8/bin/clang+0xceab4a)
#20 0x00005581c3f973bd
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-3.8/bin/clang+0x86f3bd)
#21 0x00005581c40105d3
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib/llvm-3.8/bin/clang+0x8e85d3)
#22 0x00005581c40119e3
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib/llvm-3.8/bin/clang+0x8e99e3)
#23 0x00005581c4011cbf
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib/llvm-3.8/bin/clang+0x8e9cbf)
#24 0x00005581c3fa76c7 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-3.8/bin/clang+0x87f6c7)
#25 0x00005581c3f88531
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib/llvm-3.8/bin/clang+0x860531)
#26 0x00005581c3f88ee4
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-3.8/bin/clang+0x860ee4)                                          

#27 0x00005581c3f7d99b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-3.8/bin/clang+0x85599b)                                          

#28 0x00005581c3dd7bf6 clang::FrontendAction::Execute()
(/usr/lib/llvm-3.8/bin/clang+0x6afbf6)                                          

#29 0x00005581c3dad636
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-3.8/bin/clang+0x685636)                                          

#30 0x00005581c3e519c3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-3.8/bin/clang+0x7299c3)                                          

#31 0x00005581c3aeb2a0 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*)
(/usr/lib/llvm-3.8/bin/clang+0x3c32a0)                                          

#32 0x00005581c3ae7c0e main
(/usr/lib/llvm-3.8/bin/clang+0x3bfc0e)                                          

#33 0x00007f821c2e32b1 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b1)                                       

#34 0x00005581c3ae965a _start
(/usr/lib/llvm-3.8/bin/clang+0x3c165a)                                          

Stack
dump:                                                                           

0.      Program arguments: /usr/lib/llvm-3.8/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name main.cpp -mrelocation-model
static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu
x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-file
/home/<username>/work/tmp/bldClang/CMakeFiles/test_project.dir/main.cpp.o
-resource-dir /usr/lib/llvm-3.8/bin/../lib/clang/3.8.1 -dependency-file
CMakeFiles/test_project.dir/main.cpp.o.d -sys-header-deps -MT
CMakeFiles/test_project.dir/main.cpp.o -I ../ -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-3.8/bin/../lib/clang/3.8.1/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -fdeprecated-macro -fdebug-compilation-dir
/home/<username>/work/tmp/bldClang -ferror-limit 19 -fmessage-length 0
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -o CMakeFiles/test_project.dir/main.cpp.o -x
c++ /home/<username>/work/tmp/main.cpp
1.      /home/<username>/work/tmp/main.cpp:7:38: current parser token ';'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.1-18 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ 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/main-905097.cpp
clang: note: diagnostic msg: /tmp/main-905097.sh
clang: note: diagnostic msg:

********************
ninja: build stopped: subcommand failed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170418/8ed1969a/attachment.html>


More information about the llvm-bugs mailing list