[llvm-bugs] [Bug 49630] New: Assertion failure with invalid code, fatal errors, and unused warning as error "Unaccounted cleanups in function"

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 18 10:19:30 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49630

            Bug ID: 49630
           Summary: Assertion failure with invalid code, fatal errors, and
                    unused warning as error "Unaccounted cleanups in
                    function"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code

```
template<typename T>
void a(T &&s) {
}

void b() {
        int sum = a(0);
}
```

when compiled with `clang++ -Werror=unused-parameter -Wfatal-errors -o
/dev/null -c ~/test/crash.cpp`

causes clang to crash with

```
/home/david/test/crash.cpp:2:12: fatal error: unused parameter 's'
[-Wunused-parameter]
void a(T &&s) {
           ^
clang++: /home/david/llvm/clang/lib/Sema/SemaDecl.cpp:14661: 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://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -Werror=unused-parameter -Wfatal-errors -o
/dev/null -c /home/david/test/crash.cpp
1.      <eof> parser at end of file
2.      /home/david/test/crash.cpp:5:10: parsing function body 'b'
 #0 0x0000564da2880f6d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/david/llvm/build/bin/clang-13+0x1f46f6d)
 #1 0x0000564da287eb84 llvm::sys::RunSignalHandlers()
(/home/david/llvm/build/bin/clang-13+0x1f44b84)
 #2 0x0000564da27e0228 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fc991af6960 __restore_rt sigaction.c:0:0
 #4 0x00007fc99153bef5 raise (/usr/lib/libc.so.6+0x3cef5)
 #5 0x00007fc991525862 abort (/usr/lib/libc.so.6+0x26862)
 #6 0x00007fc991525747 _nl_load_domain.cold loadmsgcat.c:0:0
 #7 0x00007fc991534646 (/usr/lib/libc.so.6+0x35646)
 #8 0x0000564da4b68e92 clang::Sema::ActOnFinishFunctionBody(clang::Decl*,
clang::Stmt*, bool) (/home/david/llvm/build/bin/clang-13+0x422ee92)
 #9 0x0000564da498b717 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/home/david/llvm/build/bin/clang-13+0x4051717)
#10 0x0000564da48cda02
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/david/llvm/build/bin/clang-13+0x3f93a02)
#11 0x0000564da48fa1ab clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/david/llvm/build/bin/clang-13+0x3fc01ab)
#12 0x0000564da48ca582
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#13 0x0000564da48d0ad6
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/home/david/llvm/build/bin/clang-13+0x3f96ad6)
#14 0x0000564da48d17b8
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/david/llvm/build/bin/clang-13+0x3f977b8)
#15 0x0000564da48c3e09 clang::ParseAST(clang::Sema&, bool, bool)
(/home/david/llvm/build/bin/clang-13+0x3f89e09)
#16 0x0000564da320f6a9 clang::FrontendAction::Execute()
(/home/david/llvm/build/bin/clang-13+0x28d56a9)
#17 0x0000564da31a0095
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/david/llvm/build/bin/clang-13+0x2866095)
#18 0x0000564da32d2663
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/david/llvm/build/bin/clang-13+0x2998663)
#19 0x0000564da14fb641 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/david/llvm/build/bin/clang-13+0xbc1641)
#20 0x0000564da14f6df0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#21 0x0000564da3034185 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#22 0x0000564da27e03b4
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/david/llvm/build/bin/clang-13+0x1ea63b4)
#23 0x0000564da303539b
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#24 0x0000564da3007ee8
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/david/llvm/build/bin/clang-13+0x26cdee8)
#25 0x0000564da3008a19
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/home/david/llvm/build/bin/clang-13+0x26cea19)
#26 0x0000564da3014ce1
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/home/david/llvm/build/bin/clang-13+0x26dace1)
#27 0x0000564da1463748 main (/home/david/llvm/build/bin/clang-13+0xb29748)
#28 0x00007fc991526b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#29 0x0000564da14f676e _start (/home/david/llvm/build/bin/clang-13+0xbbc76e)
clang-13: fatal error: clang frontend command failed with exit code 134 (use -v
to see invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
420d90d8137e9de7cda7c948f43ea4e50703d75f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david/llvm/build/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/crash-968831.cpp
clang-13: note: diagnostic msg: /tmp/crash-968831.sh
clang-13: note: diagnostic msg: 

********************
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210318/8b70e761/attachment-0001.html>


More information about the llvm-bugs mailing list