-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]
Description
Description
I encountered a crash in Clang-20 when compiling the following code snippet:
int main() {
double x = 37;
// clang doesn't accept that
__auto_type restrict xr = &x;
restrict __auto_type rx = &x;
__auto_type _Atomic xa = x;
_Atomic __auto_type ax = x;
}$ clang -v
Ubuntu clang version 20.0.0 (++20241128033836+45b567be8d0d-1~exp1~20241128153857.2079)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64Command
The compilation command used was:
clang -fno-rtlib-add-rpath -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address test.cError Message
<source>:4:24: warning: unused variable 'xr' [-Wunused-variable]
4 | __auto_type restrict xr = &x;
| ^~
<source>:5:24: warning: unused variable 'rx' [-Wunused-variable]
5 | restrict __auto_type rx = &x;
| ^~
<source>:6:23: warning: unused variable 'xa' [-Wunused-variable]
6 | __auto_type _Atomic xa = x;
| ^~
<source>:7:24: warning: unused variable 'ax' [-Wunused-variable]
7 | _Atomic __auto_type ax = x;
| ^~
clang: /root/llvm-project/clang/lib/AST/ASTContext.cpp:2394: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const: Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto 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 -fno-rtlib-add-rpath -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address <source>
1. <eof> parser at end of file
2. <source>:1:5: LLVM IR generation of declaration 'main'
3. <source>:1:5: Generating code for declaration 'main'
#0 0x0000000003c02b58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c02b58)
#1 0x0000000003c0085c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c0085c)
#2 0x0000000003b4df48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f3141042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f31410969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007f3141042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007f31410287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007f314102871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007f3141039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000073aa31d clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73aa31d)
#10 0x00000000073934e7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73934e7)
#11 0x00000000073aa404 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73aa404)
#12 0x00000000073934e7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73934e7)
#13 0x00000000073abfcb clang::ASTContext::getPreferredTypeAlign(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73abfcb)
#14 0x00000000073acacb clang::ASTContext::getDeclAlign(clang::Decl const*, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73acacb)
#15 0x00000000043b93d1 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43b93d1)
#16 0x00000000043bfdbb clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#17 0x00000000043c0016 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43c0016)
#18 0x0000000003f5d7f7 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f5d7f7)
#19 0x0000000003f74749 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f74749)
#20 0x0000000003f6c3b5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f6c3b5)
#21 0x0000000003f74164 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f74164)
#22 0x0000000003fdd1b4 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fdd1b4)
#23 0x0000000003ff017c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ff017c)
#24 0x0000000004057d4a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4057d4a)
#25 0x0000000004052fb5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4052fb5)
#26 0x000000000405339b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x405339b)
#27 0x000000000405db73 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#28 0x000000000458bd06 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#29 0x000000000457ca38 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457ca38)
#30 0x00000000065342f4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x65342f4)
#31 0x00000000045898b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45898b8)
#32 0x0000000004843f99 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4843f99)
#33 0x00000000047c3eae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47c3eae)
#34 0x000000000492efae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x492efae)
#35 0x0000000000caec91 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcaec91)
#36 0x0000000000ca681a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x00000000045ccac9 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
#38 0x0000000003b4e3f4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b4e3f4)
#39 0x00000000045cd0bf 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
#40 0x000000000459339d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459339d)
#41 0x000000000459448d 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+0x459448d)
#42 0x000000000459b845 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x459b845)
#43 0x0000000000cabac3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcabac3)
#44 0x0000000000b7f544 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb7f544)
#45 0x00007f3141029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007f3141029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000ca62ce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca62ce)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/sqE35r9ne
Please let me know if you need any more details.
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]