Crash while compiling code
| Bugzilla Link | 50675 |
| Version | trunk |
| OS | Linux |
| CC | @DougGregor,@zygoloid |
Extended Description
Dear LLVM maintainers,
Playing with C++ code in an online playground, I found that the code generates an issue in the LLVM compiler.
The code with the error message and stack trace are available online by the link https://gcc.godbolt.org/z/f1TaoobEE .
Also the code and the stack trace are below and it does not require any script to reproduce.
The code:
------------- cut here -------------
template<class C> struct Data { template<typename T> struct Item1 { void Test() { } }; };
template <class C>
struct MyData : Data<C> {
class Data<C>::template Item1
struct S;
MyData<S> dataS;
------------- cut here -------------
The error description and the call stack:
------------- cut here -------------
clang++: tools/clang/include/clang/AST/TypeNodes.inc:70: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++11
-
:15:16: current parser token ';'
#0 0x0000557182df2def PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000557182df0c10 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x379bc10)
#2 0x0000557182d40ac8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f3f6f7193c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f3f6f1e918b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
#5 0x00007f3f6f1c8859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
#6 0x00007f3f6f1c8729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
#7 0x00007f3f6f1d9f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#8 0x00005571856eabe2 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6095be2)
#9 0x00005571856e99d2 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60949d2)
#10 0x00005571856e9c71 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6094c71)
#11 0x00005571856e99d2 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60949d2)
#12 0x00005571856f7a7b clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60a2a7b)
#13 0x00005571856f7bc6 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60a2bc6)
#14 0x00005571859ff954 (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutField(clang::FieldDecl const*, bool)::'lambda'(bool)::operator()(bool) const RecordLayoutBuilder.cpp:0:0
#15 0x0000557185a0cb4f (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutField(clang::FieldDecl const*, bool) RecordLayoutBuilder.cpp:0:0
#16 0x0000557185a0d319 (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutFields(clang::RecordDecl const*) RecordLayoutBuilder.cpp:0:0
#17 0x0000557185a0f0e0 (anonymous namespace)::ItaniumRecordLayoutBuilder::Layout(clang::CXXRecordDecl const*) RecordLayoutBuilder.cpp:0:0
#18 0x0000557185a08fa7 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b3fa7)
#19 0x00005571856ea91d clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x609591d)
#20 0x00005571856e99d2 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x60949d2)
#21 0x00005571856e9b5e clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6094b5e)
#22 0x0000557184dd40b0 clang::Sema::CheckArgAlignment(clang::SourceLocation, clang::NamedDecl*, llvm::StringRef, clang::QualType, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x577f0b0)
#23 0x0000557184dfe35b clang::Sema::CheckConstructorCall(clang::FunctionDecl*, clang::QualType, llvm::ArrayRef<clang::Expr const*>, clang::FunctionProtoType const*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x57a935b)
#24 0x0000557184f21df8 clang::Sema::CompleteConstructorCall(clang::CXXConstructorDecl*, clang::QualType, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, llvm::SmallVectorImplclang::Expr*&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x58ccdf8)
#25 0x000055718517ffdf PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRefclang::Expr*, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#26 0x000055718519235d clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRefclang::Expr*, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5b3d35d)
#27 0x0000557184eba2e2 clang::Sema::ActOnUninitializedDecl(clang::Decl*) (.part.3353) SemaDecl.cpp:0:0
#28 0x0000557184c8e26b clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x563926b)
#29 0x0000557184c9ed5a clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5649d5a)
#30 0x0000557184c78929 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5623929)
#31 0x0000557184c79071 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.280) Parser.cpp:0:0
#32 0x0000557184c79260 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5624260)
#33 0x0000557184c79eb9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5624eb9)
#34 0x0000557184c70009 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x561b009)
#35 0x0000557183da18f8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x474c8f8)
#36 0x0000557183702241 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40ad241)
#37 0x000055718369e92a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x404992a)
#38 0x00005571837d03ba clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x417b3ba)
#39 0x00005571809e151c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x138c51c)
#40 0x00005571809dc8c9 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#41 0x0000557183550015 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits
This still reproduces on post 16 trunk (12e9c7aaa66b7624b5d7666ce2794d912bf9e4b7)
https://gcc.godbolt.org/z/jxjxbazM7
I am copying the code and backtrace here to fix formatting and make it easier to read
template<class C> struct Data {
template<typename T> struct Item1 {
void Test() {
}
};
};
template <class C>
struct MyData : Data<C> {
class Data<C>::template Item1<int> item10; // (1)
};
struct S;
MyData<S> dataS;
The Assert that gets triggered is
clang++: /root/build/tools/clang/include/clang/AST/TypeNodes.inc:71:
clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const:
Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
The full backtrace
clang++: /root/build/tools/clang/include/clang/AST/TypeNodes.inc:71: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:15:16: current parser token ';'
#0 0x000055c9433f4f2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c52f2f)
#1 0x000055c9433f2c9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c50c9c)
#2 0x000055c94333d398 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f49c8b3b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f49c860800b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f49c85e7859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f49c85e7729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f49c85f8fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055c946a92e8d clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72f0e8d)
#9 0x000055c946a8041f clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72de41f)
#10 0x000055c946a91f9b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72eff9b)
#11 0x000055c946a8041f clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72de41f)
#12 0x000055c946a93153 clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72f1153)
#13 0x000055c946a932bb clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72f12bb)
#14 0x000055c946eef0a5 (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutField(clang::FieldDecl const*, bool) RecordLayoutBuilder.cpp:0:0
#15 0x000055c946ef093f (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutFields(clang::RecordDecl const*) RecordLayoutBuilder.cpp:0:0
#16 0x000055c946eed731 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x774b731)
#17 0x000055c946a92ce1 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72f0ce1)
#18 0x000055c946a8041f clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72de41f)
#19 0x000055c946a91e1b clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72efe1b)
#20 0x000055c945d50cf0 clang::Sema::CheckArgAlignment(clang::SourceLocation, clang::NamedDecl*, llvm::StringRef, clang::QualType, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65aecf0)
#21 0x000055c945d884cc clang::Sema::CheckConstructorCall(clang::FunctionDecl*, clang::QualType, llvm::ArrayRef<clang::Expr const*>, clang::FunctionProtoType const*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65e64cc)
#22 0x000055c945f7331c clang::Sema::CompleteConstructorCall(clang::CXXConstructorDecl*, clang::QualType, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, llvm::SmallVectorImpl<clang::Expr*>&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67d131c)
#23 0x000055c9462d2045 PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#24 0x000055c9462e6c68 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b44c68)
#25 0x000055c945ec5ff5 clang::Sema::ActOnUninitializedDecl(clang::Decl*) (.part.0) SemaDecl.cpp:0:0
#26 0x000055c945b95fd4 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63f3fd4)
#27 0x000055c945ba35c8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64015c8)
#28 0x000055c945b704b1 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63ce4b1)
#29 0x000055c945b70d6f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#30 0x000055c945b77711 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d5711)
#31 0x000055c945b78086 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d6086)
#32 0x000055c945b6be2a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63c9e2a)
#33 0x000055c94466e9a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ecc9a8)
#34 0x000055c943eb8b79 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4716b79)
#35 0x000055c943e3e4c6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x469c4c6)
#36 0x000055c943f9d2a6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47fb2a6)
#37 0x000055c9408970ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10f50ed)
#38 0x000055c940892dea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x000055c943c9d23d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#40 0x000055c94333d8a0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9b8a0)
#41 0x000055c943c9d85f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#42 0x000055c943c649ec clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c29ec)
#43 0x000055c943c6547d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c347d)
#44 0x000055c943c6d55d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44cb55d)
#45 0x000055c94089534a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10f334a)
#46 0x000055c94079b5c5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xff95c5)
#47 0x00007f49c85e9083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#48 0x000055c94088dbce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10ebbce)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
@llvm/issue-subscribers-clang-frontend