Issue 137276
Summary Assertion failure in clang::CodeGen::CodeGenTypes::isPointerZeroInitializable(clang::QualType)
Labels clang
Assignees
Reporter alexfh
    Assertions-enabled Clang crashes on this input:
```
typedef unsigned long uint64_t;
struct R {
  uint64_t args[3];
};
template <class... Ts>
void g(Ts... args) {
  R r{.args = {uint64_t(args)...}};
}
struct S {
  virtual void f() {
 g(0, nullptr);
  }
};
S s;
```
https://gcc.godbolt.org/z/MPTnM1961

```
clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:853: bool clang::CodeGen::CodeGenTypes::isPointerZeroInitializable(clang::QualType): Assertion `(T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type"' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:6:6: Generating code for declaration 'g'
 #0 0x0000000003ef3f78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef3f78)
 #1 0x0000000003ef1c04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef1c04)
 #2 0x0000000003e36738 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007c1819042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007c18190969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007c1819042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007c18190287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007c181902871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007c1819039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000004502e2c clang::CodeGen::CodeGenTypes::isPointerZeroInitializable(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502e2c)
#10 0x0000000004260b99 isSimpleZero(clang::Expr const*, clang::CodeGen::CodeGenFunction&) CGExprAgg.cpp:0:0
#11 0x000000000426324c GetNumNonZeroBytesInInit(clang::Expr const*, clang::CodeGen::CodeGenFunction&) CGExprAgg.cpp:0:0
#12 0x00000000042633f3 GetNumNonZeroBytesInInit(clang::Expr const*, clang::CodeGen::CodeGenFunction&) CGExprAgg.cpp:0:0
#13 0x0000000004263600 GetNumNonZeroBytesInInit(clang::Expr const*, clang::CodeGen::CodeGenFunction&) CGExprAgg.cpp:0:0
#14 0x000000000426dcf8 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426dcf8)
#15 0x00000000047e4162 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47e4162)
#16 0x00000000047f0002 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47f0002)
#17 0x00000000047f0766 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#18 0x00000000047f0f67 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47f0f67)
#19 0x00000000043bc7bc clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43bc7bc)
#20 0x00000000043d25d2 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43d25d2)
#21 0x00000000043ca085 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43ca085)
#22 0x00000000043d206c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43d206c)
#23 0x0000000004437f22 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4437f22)
#24 0x000000000444b2d5 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x444b2d5)
#25 0x00000000044b51fa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b51fa)
#26 0x00000000044aff94 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44aff94)
#27 0x00000000044bc317 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44bc317)
#28 0x00000000044bc238 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44bc238)
#29 0x00000000044be8a3 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44be8a3)
#30 0x000000000489523e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#31 0x00000000048916a5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48916a5)
#32 0x000000000655258c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x655258c)
#33 0x0000000004891e38 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4891e38)
#34 0x0000000004b84f85 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b84f85)
#35 0x0000000004b03d4e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b03d4e)
#36 0x0000000004c73e7e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c73e7e)
#37 0x0000000000d9f3af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9f3af)
#38 0x0000000000d963ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x00000000048f84f9 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 0x0000000003e36bd4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e36bd4)
#41 0x00000000048f8b0f 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 0x00000000048baf6d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48baf6d)
#43 0x00000000048bbffe 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+++0x48bbffe)
#44 0x00000000048c3e55 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c3e55)
#45 0x0000000000d9c0f8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9c0f8)
#46 0x0000000000c236a4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc236a4)
#47 0x00007c1819029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#48 0x00007c1819029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#49 0x0000000000d95e65 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd95e65)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to