<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63706>63706</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion `!Cleanup.exprNeedsCleanups() && "Unaccounted cleanups in function"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Colton1skees
</td>
</tr>
</table>
<pre>
The following code
```
// Defined values for the exception filter expression
#define EXCEPTION_EXECUTE_HANDLER 1
// SEH intrinsics
#define GetExceptionCode _exception_code
#define GetExceptionInformation() ((struct _EXCEPTION_POINTERS *)_exception_info())
#define exception_info() ((struct _EXCEPTION_POINTERS *)_exception_info())
void * __cdecl _exception_info(void);
void run(int variable)
{
__try {
auto stuff = 1232434 / variable;
}
__except ([variable](unsigned int code, struct _EXCEPTION_POINTERS* ep) -> int
{
int fault_here = variable;
return EXCEPTION_EXECUTE_HANDLER;
}(GetExceptionCode(), GetExceptionInformation()))
{
}
```
causes clang to crash with
```
clang++: /root/llvm-project/clang/lib/Sema/SemaDecl.cpp:15944: clang::Decl* clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool): Assertion `!Cleanup.exprNeedsCleanups() && "Unaccounted cleanups in function"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -emit-llvm -O3 -target x86_64-pc-windows-msvc <source>
1. <eof> parser at end of file
2. <source>:12:1: parsing function body 'run'
#0 0x000056334e1b281f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c3381f)
#1 0x000056334e1b058c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c3158c)
#2 0x000056334e0fab98 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f8afec11420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f8afe6de00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f8afe6bd859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f8afe6bd729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f8afe6cefd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000563350cd7b4a clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6758b4a)
#9 0x0000563350a49c1d clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64cac1d)
#10 0x0000563350974871 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63f5871)
#11 0x000056335099b750 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x641c750)
#12 0x0000563350968111 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63e9111)
#13 0x00005633509689cf clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#14 0x000056335096f371 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63f0371)
#15 0x000056335096fce6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63f0ce6)
#16 0x0000563350963a8a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63e4a8a)
#17 0x000056334f438a68 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eb9a68)
#18 0x000056334ec7ba69 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46fca69)
#19 0x000056334ec009f6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46819f6)
#20 0x000056334ed60b16 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47e1b16)
#21 0x000056334b68fd94 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1110d94)
#22 0x000056334b68baba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x000056334ea5a89d 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
#24 0x000056334e0fb0a0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b7c0a0)
#25 0x000056334ea5aebf 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
#26 0x000056334ea21a9c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44a2a9c)
#27 0x000056334ea2252d 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+++0x44a352d)
#28 0x000056334ea2a60d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44ab60d)
#29 0x000056334b68e00a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x110f00a)
#30 0x000056334b5935f5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10145f5)
#31 0x00007f8afe6bf083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x000056334b68689e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x110789e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
It's still an issue on trunk: https://godbolt.org/z/ehYdMeEvY
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z46jS_jXKDaUUQt8XufA4zm62ZmemJtm3dq9cCLVs3pFBB1DinF9_CiTHQnG82VPJ3BxXxmMjuul-eOhuwFRrvhEAV0H6KUivL2hvtlJdLWVrpIj0DwB9Ucn66ep-C6iRbSsfudggJmsI8HWAF-N7hse_4Su5CcgNuoaGC6jRA2170KiRCpktINgz6AyXAjW8NaAQ7DsFWnMpDuJx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