<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Assertion failure with invalid code, fatal errors, and unused warning as error "Unaccounted cleanups in function""
   href="https://bugs.llvm.org/show_bug.cgi?id=49630">49630</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion failure with invalid code, fatal errors, and unused warning as error "Unaccounted cleanups in function"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david@doublewise.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> 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>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
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>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
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 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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: 

********************
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>