[llvm-bugs] [Bug 52005] New: Compiler crash when incorrectly define template variable with auto type

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 28 13:18:04 PDT 2021


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

            Bug ID: 52005
           Summary: Compiler crash when incorrectly define template
                    variable with auto type
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2b
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fchelnokov at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The code as follows:
```
template <typename T>
auto p = p<T>;

auto x = p<int>;
```

crashes the compiler:
https://gcc.godbolt.org/z/a99aThzjj

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-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++20 -Wall -Wextra -pedantic-errors <source>
1.      <eof> parser at end of file
2.      <source>:4:6: LLVM IR generation of declaration 'x'
3.      <source>:4:6: Generating code for declaration 'x'
 #0 0x0000556e3b7a626f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000556e3b7a4130 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35a4130)
 #2 0x0000556e3b6f4b38 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fd94dedf3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x0000556e3ae87c04 llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c87c04)
 #5 0x0000556e3ae91adf llvm::Constant::getNullValue(llvm::Type*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c91adf)
 #6 0x0000556e3baeda1d
clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38eda1d)
 #7 0x0000556e3bb8daa7
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x398daa7)
 #8 0x0000556e3bba88f5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a88f5)
 #9 0x0000556e3bba913b
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a913b)
#10 0x0000556e3bbaeded
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5289)
CodeGenModule.cpp:0:0
#11 0x0000556e3c7474c1 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
ModuleBuilder.cpp:0:0
#12 0x0000556e3c73ab32
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x453ab32)
#13 0x0000556e3d59f544 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x539f544)
#14 0x0000556e3c7453b2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x45453b2)
#15 0x0000556e3c0db771 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3edb771)
#16 0x0000556e3c078382
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e78382)
#17 0x0000556e3c1a8b93
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fa8b93)
#18 0x0000556e394d71ec cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d71ec)
#19 0x0000556e394d325d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#20 0x0000556e3bf1cee5 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
#21 0x0000556e3b6f5123
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f5123)
#22 0x0000556e3bf1ef9e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d1ef9e)
#23 0x0000556e3bef490a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf490a)
#24 0x0000556e3bef544f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf544f)
#25 0x0000556e3befe885
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cfe885)
#26 0x0000556e393e71de main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x11e71de)
#27 0x00007fd94d98f0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#28 0x0000556e394d2dda _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d2dda)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
ASM generation compiler returned: 139

-- 
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/20210928/b54cc288/attachment.html>


More information about the llvm-bugs mailing list