<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63550>63550</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: Assertion `VarSize == CstSize && "Emitted constant has unexpected size"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wierton
</td>
</tr>
</table>
<pre>
The testcase:
```
_Atomic(unsigned int) a;
_Atomic(int *) b = 0;
void c(int x) { a << x; }
```
Compiler Explorer: https://gcc.godbolt.org/z/zcef1aTbP
```
$ clang --version
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 12e9c7aaa66b7624b5d7666ce2794d912bf9e4b7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
$ clang -O0 small.c
clang: /root/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5182: void clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(const clang::VarDecl*, bool): Assertion `VarSize == CstSize && "Emitted constant has unexpected size"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1. <source>:3:1: current parser token 'void'
2. <source>:2:16: LLVM IR generation of declaration 'b'
3. <source>:2:16: Generating code for declaration 'b'
#0 0x0000561c7878cf2f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c52f2f)
#1 0x0000561c7878ac9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c50c9c)
#2 0x0000561c786d5398 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f847dd8c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f847d85900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f847d838859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f847d838729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f847d849fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000561c78b6e346 clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4034346)
#9 0x0000561c78b90d21 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4056d21)
#10 0x0000561c78b91988 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4057988)
#11 0x0000561c78b9a734 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#12 0x0000561c79a09ac6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#13 0x0000561c799fbb70 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ec1b70)
#14 0x0000561c7af03e14 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x63c9e14)
#15 0x0000561c79a069a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ecc9a8)
#16 0x0000561c79250b79 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4716b79)
#17 0x0000561c791d64c6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x469c4c6)
#18 0x0000561c793352a6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47fb2a6)
#19 0x0000561c75c2f0ed cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f50ed)
#20 0x0000561c75c2adea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000561c7903523d 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
#22 0x0000561c786d58a0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b9b8a0)
#23 0x0000561c7903585f 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
#24 0x0000561c78ffc9ec clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c29ec)
#25 0x0000561c78ffd47d 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+0x44c347d)
#26 0x0000561c7900555d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44cb55d)
#27 0x0000561c75c2d34a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f334a)
#28 0x0000561c75b335c5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xff95c5)
#29 0x00007f847d83a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#30 0x0000561c75c25bce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10ebbce)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWd9z26gW_mvIC2MPAv188IPjxL3tdKedJtNXDyBkcyOBBlDi9K-_gyQ7wnGybde9Lzuz2VqADt_3cTjnIKi1cquEWIDkGiQ3V7RzO20WT1IYp9UV0-Xz4n4noBPWcWoFIEuAbgBaghSN__WPm6XTjeQA553qLZZQKgdwASkg16djpHIQ4KXvZhCQG4iOgx61LOFhzN6PANk1pBCQFSAruAfkGoLs5iyI4f8r3bSyFgbe7ttaG2EAWcKdc6314PEa4PWW8_lWl0zXbq7NFuD1D__HRRXRe_b1vHEcQ15TtYWz2aMwVmo1dAyNYxOMsjmaIwhwfjKldLuOzbluAF7X9ePhn1lr9H8Fd_OtdDDCouAZpTRNWZbimCVllqYpFzgr4rKIMKsKEbMM4GKY-56arXCe4D5PN2k869SD0k9qVkvV7Wdb1Y3jdkbQEja6FLUf3Wor90PXR2UdrWtR3sheKYDXunUAr_mo40wcdMTrnuuMWiuMk1rZmTOdegB4zaQ6Ud8I1xklSm_ztYRfELQNres5n4g4Tm-0difqHKb2zZIBvF7pUnwQ6uXXX7rsajHnbQvIMoly7I0NzjSaBmR5eGv6MLw4NN020n2oNaP1d2puRCWV9DQBzrlW1k1N9QN43XvxCjKta78oZAmXB3EgSNF3au7kD-F93Lv5yrrhEacApxBg7Gd0ooS9faoc3FELOyX2reC-3cofAmAMcAYrKmtRzge9vn6-Xd7dQtuxRjpIIeu20IhWGw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