Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static member auto variable template with template-template parameter, inside struct with template-template parameter, crashes compiler #49085

Open
Matthewacon opened this issue Mar 27, 2021 · 5 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@Matthewacon
Copy link
Member

Matthewacon commented Mar 27, 2021

Bugzilla Link 49741
Version unspecified
OS Linux
Attachments Compiler crash backtrace, Run script
CC @zygoloid

Extended Description

See attachment for compiler backtrace.

Affected versions:

  • trunk
  • 11.0.1
  • 11.0.0
  • 10.0.1
  • 10.0.0
  • 9.0.1
  • 9.0.0

Driver cmdline:
Note: For versions that do not support -std=c++20, -std=c++2a was used.

clang++ -Xclang -disable-llvm-passes -std=c++20

Note: The original code has been reduced with creduce.
Reduced code:

template <template <typename> typename> struct a {
  template <template <typename> typename> static auto const b = false;
};
template <typename> struct c;
int main() { a<c>::b<c>; }


Original code:

template<template<typename...> typename T>
struct Receiver {
 template<template<typename...> typename Other>
 static constexpr auto const value = false;
};

template<typename...>
struct A;

void f(auto) {}

int main() {
 f(Receiver<A>::value<A>);
 return 0;
}
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@Endilll
Copy link
Contributor

Endilll commented Sep 10, 2023

Still crashing as of post-17 trunk: https://godbolt.org/z/5WEY8xd7f

<source>:5:14: warning: expression result unused [-Wunused-value]
    5 | int main() { a<c>::b<c>; }
      |              ^~~~~~~~~~

Unexpected undeduced type!
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenTypes.cpp:545!

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>:5:5: LLVM IR generation of declaration 'main'
3.	<source>:5:5: Generating code for declaration 'main'
 #0 0x00000000036afc28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36afc28)
 #1 0x00000000036ad8ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ad8ec)
 #2 0x00000000035f6d08 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fcdc4a9d420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fcdc456000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fcdc453f859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x0000000003601fba (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3601fba)
 #7 0x0000000003aeb832 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aeb832)
 #8 0x0000000003aec739 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aec739)
 #9 0x0000000003a80601 clang::CodeGen::CodeGenModule::GetAddrOfGlobalVar(clang::VarDecl const*, llvm::Type*, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a80601)
#10 0x0000000003db88ab clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3db88ab)
#11 0x0000000003db47a1 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3db47a1)
#12 0x0000000003dc01d5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dc01d5)
#13 0x00000000039caca2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39caca2)
#14 0x00000000039d113c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39d113c)
#15 0x0000000003a2eab6 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a2eab6)
#16 0x0000000003a41c5a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a41c5a)
#17 0x0000000003aa2fe3 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3aa2fe3)
#18 0x0000000003a9e0d5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9e0d5)
#19 0x0000000003a9e69b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9e69b)
#20 0x0000000003aa7b13 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#21 0x00000000049126c6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#22 0x00000000049032d8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49032d8)
#23 0x0000000005e04a04 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e04a04)
#24 0x000000000490f578 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490f578)
#25 0x0000000004177f89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4177f89)
#26 0x00000000040f818e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40f818e)
#27 0x00000000042561fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42561fe)
#28 0x0000000000bd6ea0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd6ea0)
#29 0x0000000000bcf0ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x0000000003f59309 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
#31 0x00000000035f71b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35f71b4)
#32 0x0000000003f598ff 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
#33 0x0000000003f21c85 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f21c85)
#34 0x0000000003f226ed 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+++0x3f226ed)
#35 0x0000000003f2a615 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2a615)
#36 0x0000000000bd4cac clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd4cac)
#37 0x0000000000ad14a1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xad14a1)
#38 0x00007fcdc4541083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#39 0x0000000000bcebae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcebae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)

@Endilll Endilll added c clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 10, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2023

@llvm/issue-subscribers-clang-codegen

@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2023

@llvm/issue-subscribers-c

@Endilll Endilll added c++ and removed c labels Sep 10, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2023

@llvm/issue-subscribers-c-1

@shafik
Copy link
Collaborator

shafik commented Sep 10, 2023

Possibly related: #47028

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants