<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/138653>138653</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ICE / LLVM ERROR: Out of memory when compiling large std::array<shared_future<...>> with additional unexpected behaviours (C++23, Clang 19–21)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mariete1223
</td>
</tr>
</table>
<pre>
## Summary
LLVM ERROR: out of memory strange error, it occurs with std=c++23 and versions 19, 20 and current, it has been found that in current version if you remove #include <thread> the compiler does not crashes but in version 20 and 19 it does.
## Assertion
No assertion given
## Stack dump
```
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 -x c++ -std=c++23 <source>
1. <source>:9:81: current parser token ';'
2. <source>:8:12: parsing function body 'main'
3. <source>:8:12: in compound statement ('{}')
#0 0x0000000003f70b58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f70b58)
#1 0x0000000003f6e7e4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f6e7e4)
#2 0x0000000003eb36a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007d9110042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007d91100969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007d9110042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007d91100287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003ebeeab (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ebeeab)
#8 0x0000000003ebeec5 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ebeec5)
#9 0x00007d91104ae9a3 operator new(unsigned long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xae9a3)
#10 0x00000000074b318c clang::APValue::MakeArray(unsigned int, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74b318c)
#11 0x000000000788d422 (anonymous namespace)::ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(clang::Expr const*, llvm::ArrayRef<clang::Expr*>, clang::Expr const*, clang::QualType) ExprConstant.cpp:0:0
#12 0x00000000078c4faf clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ArrayExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#13 0x00000000078c65cd EvaluateArray(clang::Expr const*, (anonymous namespace)::LValue const&, clang::APValue&, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#14 0x000000000788bd11 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) ExprConstant.cpp:0:0
#15 0x000000000788ed06 (anonymous namespace)::RecordExprEvaluator::VisitCXXParenListOrInitListExpr(clang::Expr const*, llvm::ArrayRef<clang::Expr*>) ExprConstant.cpp:0:0
#16 0x00000000078c94bf clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::RecordExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#17 0x00000000078ca038 EvaluateRecord(clang::Expr const*, (anonymous namespace)::LValue const&, clang::APValue&, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#18 0x000000000788bd81 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) ExprConstant.cpp:0:0
#19 0x00000000078cf690 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x78cf690)
#20 0x00000000076ecf42 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x76ecf42)
#21 0x00000000076ed0ba clang::VarDecl::evaluateValue() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x76ed0ba)
#22 0x0000000006a256d8 clang::Sema::FinalizeVarWithDestructor(clang::VarDecl*, clang::RecordType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a256d8)
#23 0x000000000698dd5b clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x698dd5b)
#24 0x00000000069957b2 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69957b2)
#25 0x00000000066189e5 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66189e5)
#26 0x00000000066286e9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66286e9)
#27 0x00000000066313a7 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66313a7)
#28 0x0000000006631869 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6631869)
#29 0x00000000066e1332 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e1332)
#30 0x00000000066e203d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e203d)
#31 0x00000000066e9d53 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e9d53)
#32 0x00000000066ea51a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66ea51a)
#33 0x00000000065f2a43 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65f2a43)
#34 0x00000000066290ed clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66290ed)
#35 0x00000000065e657e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65e657e)
#36 0x00000000065e6d39 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65e6d39)
#37 0x00000000065ee65a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65ee65a)
#38 0x00000000065ef5fd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65ef5fd)
#39 0x00000000065e19da clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65e19da)
#40 0x0000000004912908 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4912908)
#41 0x0000000004c05bb5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c05bb5)
#42 0x0000000004b851be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b851be)
#43 0x0000000004cf9a09 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cf9a09)
#44 0x0000000000da625f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda625f)
#45 0x0000000000d9c42a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#46 0x00000000049791b9 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
#47 0x0000000003eb3b44 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eb3b44)
#48 0x00000000049797cf 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
#49 0x000000000493bc1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x493bc1d)
#50 0x000000000493ccae 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+++0x493ccae)
#51 0x0000000004944b05 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4944b05)
#52 0x0000000000da21c8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda21c8)
#53 0x0000000000c27864 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc27864)
#54 0x00007d9110029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#55 0x00007d9110029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#56 0x0000000000d9bed5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9bed5)
```
## Program
```
#include <thread>
#include <future>
#include <memory>
using namespace std;
constexpr size_t kMemoryChunk = 1024 * 8;
constexpr size_t kNumberOfIterations = 2000000;
constexpr size_t kThreadsNumber = 2 * kMemoryChunk;
int main() {
array<shared_future<short*>, kThreadsNumber * kNumberOfIterations> futures{};
}
```
## Gcc Bolt
Here it can be seen stranger behaviour when include is removed.
https://gcc.godbolt.org/z/af8eKT3ax
Here in current version with include
https://gcc.godbolt.org/
## Additional question
I am also wondering if LLVM ERROR: out of memory programs are worth submiting an issue, thanks in advance
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsW1t3o7iW_jXkRcteIC6Ghzw4TtInPamTTCWr5rx5CdjYTECiJZFy-tfPkgTGwpdUeuLqnp7Tq6sKI2nr29--sEESEaJcUYBLJ7xywusL0so145c14SVI8DD2L1KWv1062Hewj57auib8zXHnjju_v__2Bd18_frw1fHniLUSsQLVUDP-hoTkhK4AAeeMO3iBSolYlrVcoO-lXCMhc8e_zhx85eAr7CNCc_QKXJSMCuQlagR29d2s5Ryo7GSsiUApAEUFa2mO5JpIVNK-Uy8ClQV6Yy3iULNXQA72S5pVbQ7I8RdyzYHkjn-D5BpQxuqmrICjnIFAlEmUcSLWIFDaatG9yA6OlygYqvMUGRo6auZCAJclo-buPxki_R20Kl-BWr2fJMleUN7WTXc7crv_3flOm6_a3KnjJo-crTipEeGrtgYqheLcwbeskQ6-7bWYwKapGAeu7lWEriZbEGIieUtfHHyblrRvNvyjySr_TngxCdBkhSZMySVNo6S3smnlVKBJXVWvNZpMNnE0IaKeiDcqycbxr0sqoUKTgrLJK_CUCVDtaPKEJpNVlk0kY1W2JiV1_OuTeFVnQUkj1kyiSZGxivFJXpIVZUKWmTBzaOvYtzco6_UYu5XjLwRreQaOf-O4c08xad3z54njz2NPsdk7UUO4AI4kewGKHDxz_Cv1tzvHB4bHjj_3sBquhpV0hYqWZtrqKnDU-FoprwX4JwUoP2Z1ox1bSCJB2Rk5OFaDZ1fO7Fpd4MRxleV9F7kbt__PL2ZuGsZIWUl5jT8Xb8JcPPKSSu1Tz5xk4OB46MTJ9yUTkgOpHRzpGFOhlphZP8W5HHzlbjp4A3jPBh_BDIJD4BcVENo2D_SpXFFSOThuqc5YOaqYmuIMUDWYASq2oELqRyRGC-WGXyFjr8DfDLZ_EJpXasa449Dqs2BUwkZOs0ZFtav_GPl-J3-WJ57nugEOsdspVZWpg283cbSMgklV0nYzWdHWNGRTwaaRhqyHDIAD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