<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63481>63481</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang ICE: Array compound literal pointer coercion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TheClonerx
</td>
</tr>
</table>
<pre>
The [Compound Literals GCC extension](https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html) page says:
> If all the elements of the compound literal are (made up of) simple constant expressions suitable for use in initializers of objects of static storage duration, then the compound literal can be coerced to a pointer to its first element and used in such an initializer.
However, when trying [this example](https://godbolt.org/z/nexb7sroE) I wrote in Compiler Explorer Clang crashes with the following stacktrace:
<details>
```
<source>:21:49: warning: string literal operator templates are a GNU extension [-Wgnu-string-literal-operator-template]
constexpr basic_string_literal<CharT, Chars...> operator""_static()
^
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-16.0.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-12.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++17 -O3 <source> -isystem/opt/compiler-explorer/libs/ctre/main/include
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:17:35: Generating code for declaration 'basic_string_literal<char, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'>::s_data'
#0 0x000055ae43bf58df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3ba18df)
#1 0x000055ae43bf390c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3b9f90c)
#2 0x000055ae43b46518 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f7a2049b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055ae473a6f48 clang::DecltypeType::desugar() const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x7352f48)
#5 0x000055ae46f4fdd0 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6efbdd0)
#6 0x000055ae46f41a55 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6eeda55)
#7 0x000055ae46f41c79 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x6eedc79)
#8 0x000055ae44052ab8 (anonymous namespace)::tryEmitGlobalCompoundLiteral(clang::CodeGen::ConstantEmitter&, clang::CompoundLiteralExpr const*) (.constprop.0) CGExprConstant.cpp:0:0
#9 0x000055ae440536d6 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ConstantLValueEmitter, (anonymous namespace)::ConstantLValue>::Visit(clang::Stmt const*) CGExprConstant.cpp:0:0
#10 0x000055ae440542d0 clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::APValue const&, clang::QualType) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40002d0)
#11 0x000055ae440548a6 clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::APValue const&, clang::QualType) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40008a6)
#12 0x000055ae4405607c clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl const&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x400207c)
#13 0x000055ae440562c4 clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40022c4)
#14 0x000055ae44116566 clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40c2566)
#15 0x000055ae4413af6d clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40e6f6d)
#16 0x000055ae44143d0c clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40efd0c)
#17 0x000055ae441461d9 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x40f21d9)
#18 0x000055ae44ee74ba (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#19 0x000055ae44ee5f3d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x4e91f3d)
#20 0x000055ae4610ad5d clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x60b6d5d)
#21 0x000055ae44ee5865 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x4e91865)
#22 0x000055ae447c1671 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x476d671)
#23 0x000055ae44745993 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x46f1993)
#24 0x000055ae448a5b3b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x4851b3b)
#25 0x000055ae413ce41c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x137a41c)
#26 0x000055ae413c9bdc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x000055ae445a6ce9 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
#28 0x000055ae43b46977 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x3af2977)
#29 0x000055ae445a6f1c 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
#30 0x000055ae4456f3fc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x451b3fc)
#31 0x000055ae4456fded clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x451bded)
#32 0x000055ae4457a23c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x452623c)
#33 0x000055ae413cc523 clang_main(int, char**) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x1378523)
#34 0x00007f7a1ff49083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x000055ae413c5d1e _start (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x1371d1e)
clang-16: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWktz47bS_TX0BkUVCb4XXsiyPXFq8mW-sTNZqkCgKeEOBLAA0Jbz628BpGxCIzuTiW7u4lbNgw88zuk-6G5CIMbwjQS4jIqrqLi-IIPdKn35sIWVUBL0_qJV7Nndo6i4Wqldrw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