Skip to content

Stack dump evaluating __is_constructible(Ts...) with Ts=<> #57008

Closed
@JohelEGP

Description

@JohelEGP

See https://godbolt.org/z/q39W78hsK.

template<class... Ts> bool b = __is_constructible(Ts...);
bool x = b<>;
clang++: /root/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:5307: bool evaluateTypeTrait(clang::Sema&, clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation): Assertion `!Args.empty()' 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.	<eof> parser at end of file
2.	<source>:1:28: instantiating variable definition 'b<>'
3.	<source>:1:28: instantiating variable definition 'b<>'
 #0 0x0000564b51dda464 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000564b51dd81bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e3d1bc)
 #2 0x0000564b51d0eca8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f40b8f443c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #4 0x00007f40b8a1103b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
 #5 0x00007f40b89f0859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f40b89f0729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f40b8a02006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
 #8 0x0000564b549398fa evaluateTypeTrait(clang::Sema&, clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation) SemaExprCXX.cpp:0:0
 #9 0x0000564b54939ce1 clang::Sema::BuildTypeTrait(clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x699ece1)
#10 0x0000564b54d82824 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTypeTraitExpr(clang::TypeTraitExpr*) SemaTemplateInstantiate.cpp:0:0
#11 0x0000564b54d70ed9 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#12 0x0000564b54d71c28 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (.part.0) SemaTemplateInstantiate.cpp:0:0
#13 0x0000564b54d72410 clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dd7410)
#14 0x0000564b54db60df clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e1b0df)
#15 0x0000564b54db6512 clang::Sema::CompleteVarTemplateSpecializationDecl(clang::VarTemplateSpecializationDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e1b512)
#16 0x0000564b54df7e87 clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e5ce87)
#17 0x0000564b54df8868 clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e5d868)
#18 0x0000564b544d0ad0 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#19 0x0000564b544d11ca clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65361ca)
#20 0x0000564b5437f1a0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63e41a0)
#21 0x0000564b543732ba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63d82ba)
#22 0x0000564b530d8968 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x513d968)
#23 0x0000564b5297a9b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49df9b9)
#24 0x0000564b529045ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49695ee)
#25 0x0000564b52a5a723 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4abf723)
#26 0x0000564b4f389b94 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13eeb94)
#27 0x0000564b4f382cc8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000564b52773609 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#29 0x0000564b51d0f44a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d7444a)
#30 0x0000564b52773d1f clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#31 0x0000564b5273d459 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47a2459)
#32 0x0000564b5273dedd 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+++0x47a2edd)
#33 0x0000564b52747c9c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47acc9c)
#34 0x0000564b4f387f73 clang_main(int, char**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13ecf73)
#35 0x00007f40b89f20b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#36 0x0000564b4f3828be _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13e78be)
clang-16: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ASM generation compiler returned: 134
clang-16: /root/llvm-project/clang/lib/Sema/SemaExprCXX.cpp:5307: bool evaluateTypeTrait(clang::Sema&, clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation): Assertion `!Args.empty()' 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-20220807/bin/clang-16 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20220807/lib/clang/16.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../include/c++/13.0.0/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20220807/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/app -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-fbebae.o -x c++ <source>
1.	<eof> parser at end of file
2.	<source>:1:28: instantiating variable definition 'b<>'
3.	<source>:1:28: instantiating variable definition 'b<>'
 #0 0x0000558d444ef464 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000558d444ecbd4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2b69f9f3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #3 0x00007f2b69a6c03b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
 #4 0x00007f2b69a4b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f2b69a4b729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f2b69a5d006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
 #7 0x0000558d4704e8fa evaluateTypeTrait(clang::Sema&, clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation) SemaExprCXX.cpp:0:0
 #8 0x0000558d4704ece1 clang::Sema::BuildTypeTrait(clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x699ece1)
 #9 0x0000558d47497824 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTypeTraitExpr(clang::TypeTraitExpr*) SemaTemplateInstantiate.cpp:0:0
#10 0x0000558d47485ed9 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#11 0x0000558d47486c28 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) (.part.0) SemaTemplateInstantiate.cpp:0:0
#12 0x0000558d47487410 clang::Sema::SubstInitializer(clang::Expr*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x6dd7410)
#13 0x0000558d474cb0df clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x6e1b0df)
#14 0x0000558d474cb512 clang::Sema::CompleteVarTemplateSpecializationDecl(clang::VarTemplateSpecializationDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x6e1b512)
#15 0x0000558d4750ce87 clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x6e5ce87)
#16 0x0000558d4750d868 clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x6e5d868)
#17 0x0000558d46be5ad0 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#18 0x0000558d46be61ca clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x65361ca)
#19 0x0000558d46a941a0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x63e41a0)
#20 0x0000558d46a882ba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x63d82ba)
#21 0x0000558d457ed968 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x513d968)
#22 0x0000558d4508f9b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x49df9b9)
#23 0x0000558d450195ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x49695ee)
#24 0x0000558d4516f723 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x4abf723)
#25 0x0000558d41a9eb94 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x13eeb94)
#26 0x0000558d41a97cc8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000558d41a9b135 clang_main(int, char**) (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x13eb135)
#28 0x00007f2b69a4d0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#29 0x0000558d41a978be _start (/opt/compiler-explorer/clang-assertions-trunk-20220807/bin/clang-16+0x13e78be)
clang-16: error: unable to execute command: Aborted (core dumped)
clang-16: error: clang frontend command failed due to signal (use -v to see invocation)
Execution build compiler returned: 254

Patch to fix:

--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5316,6 +5316,9 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
     //   variable t:
     //
     //     T t(create<Args>()...);
+    if (Args.empty())
+      return false;
+
     assert(!Args.empty());
 
     // Precondition: T and all types in the parameter pack Args shall be

Source: https://cpplang.slack.com/archives/C2X659D1B/p1659594865027649

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions