<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 - Segmentation fault in `PerformMoveOrCopyInitialization` with `clang++-12`"
   href="https://bugs.llvm.org/show_bug.cgi?id=51176">51176</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault in `PerformMoveOrCopyInitialization` with `clang++-12`
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>12.0
          </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>andrew.jones@vector.com
          </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>For the following file:

```
template <typename...> struct a;
template <typename> struct b { b(...); };
namespace {
auto bx() -> b<a<>> {
  b<int> w;
  return w;
}
} // namespace
```

which compiles fine with `g++-11`:

```
g++-11 -c -Wall -Wextra -Wpedantic -Werror -Wno-unused 54.cpp; echo $?
0
```

`clang++-12` crashes as follows:

```
clang++-12 -c 54.cpp
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++-12 -c 54.cpp
1.      54.cpp:6:11: current parser token ';'
2.      54.cpp:3:1: parsing namespace '(anonymous)'
3.      54.cpp:4:21: parsing function body '(anonymous namespace)::bx'
4.      54.cpp:4:21: in compound statement ('{}')
 #0 0x00007f68a5bf8c31 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/usr/bin/../lib64/libLLVM.so.12+0x290bc31)
 #1 0x00007f68a5bf64e0 llvm::sys::RunSignalHandlers()
(/usr/bin/../lib64/libLLVM.so.12+0x29094e0)
 #2 0x00007f68a5bf7f6b llvm::sys::CleanupOnSignal(unsigned long)
(/usr/bin/../lib64/libLLVM.so.12+0x290af6b)
 #3 0x00007f68a5b124c9 (/usr/bin/../lib64/libLLVM.so.12+0x28254c9)
 #4 0x00007f68a2f423a0 __restore_rt (/usr/bin/../lib64/libc.so.6+0x3d3a0)
 #5 0x00007f68aadce1dc (/usr/bin/../lib64/libclang-cpp.so.12+0x1d061dc)
 #6 0x00007f68aadcd3b4
clang::Sema::PerformMoveOrCopyInitialization(clang::InitializedEntity const&,
clang::VarDecl const*, clang::QualType, clang::Expr*, bool)
(/usr/bin/../lib64/libclang-cpp.so.12+0x1d053b4)
 #7 0x00007f68aadd145c clang::Sema::BuildReturnStmt(clang::SourceLocation,
clang::Expr*) (/usr/bin/../lib64/libclang-cpp.so.12+0x1d0945c)
 #8 0x00007f68aadd0699 clang::Sema::ActOnReturnStmt(clang::SourceLocation,
clang::Expr*, clang::Scope*) (/usr/bin/../lib64/libclang-cpp.so.12+0x1d08699)
 #9 0x00007f68aa017216 clang::Parser::ParseReturnStatement()
(/usr/bin/../lib64/libclang-cpp.so.12+0xf4f216)
#10 0x00007f68aa00fd7b
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf47d7b)
#11 0x00007f68aa00f138
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf47138)
#12 0x00007f68aa019743 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf51743)
#13 0x00007f68aa01aab5 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/bin/../lib64/libclang-cpp.so.12+0xf52ab5)
#14 0x00007f68aa036e64
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf6ee64)
#15 0x00007f68a9f7aa61 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/bin/../lib64/libclang-cpp.so.12+0xeb2a61)
#16 0x00007f68aa035e13
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf6de13)
#17 0x00007f68aa03577d
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf6d77d)
#18 0x00007f68aa0345c6
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/bin/../lib64/libclang-cpp.so.12+0xf6c5c6)
#19 0x00007f68a9f9230b
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&)
(/usr/bin/../lib64/libclang-cpp.so.12+0xeca30b)
#20 0x00007f68a9f91dca clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/usr/bin/../lib64/libclang-cpp.so.12+0xec9dca)
#21 0x00007f68a9f731eb
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*) (/usr/bin/../lib64/libclang-cpp.so.12+0xeab1eb)
#22 0x00007f68aa033add
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/bin/../lib64/libclang-cpp.so.12+0xf6badd)
#23 0x00007f68aa03272d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/usr/bin/../lib64/libclang-cpp.so.12+0xf6a72d)
#24 0x00007f68a9f5fafd clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/../lib64/libclang-cpp.so.12+0xe97afd)
#25 0x00007f68ab30a3b3 clang::CodeGenAction::ExecuteAction()
(/usr/bin/../lib64/libclang-cpp.so.12+0x22423b3)
#26 0x00007f68abdb6d74 clang::FrontendAction::Execute()
(/usr/bin/../lib64/libclang-cpp.so.12+0x2ceed74)
#27 0x00007f68abd3e00d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/../lib64/libclang-cpp.so.12+0x2c7600d)
#28 0x00007f68abe39fc6
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/../lib64/libclang-cpp.so.12+0x2d71fc6)
#29 0x0000000000213e8b cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-12.0.0+0x213e8b)
#30 0x000000000021205d (/usr/bin/clang-12.0.0+0x21205d)
#31 0x00007f68ab9a96d2 (/usr/bin/../lib64/libclang-cpp.so.12+0x28e16d2)
#32 0x00007f68a5b11e65
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/usr/bin/../lib64/libLLVM.so.12+0x2824e65)
#33 0x00007f68ab9a8f53
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
(/usr/bin/../lib64/libclang-cpp.so.12+0x28e0f53)
#34 0x00007f68ab97bce3
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/usr/bin/../lib64/libclang-cpp.so.12+0x28b3ce3)
#35 0x00007f68ab97c18a
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
const (/usr/bin/../lib64/libclang-cpp.so.12+0x28b418a)
#36 0x00007f68ab99181d
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/usr/bin/../lib64/libclang-cpp.so.12+0x28c981d)
#37 0x00000000002118f2 main (/usr/bin/clang-12.0.0+0x2118f2)
#38 0x00007f68a2f2cb35 __libc_start_main (/usr/bin/../lib64/libc.so.6+0x27b35)
#39 0x000000000020ef3e _start (/usr/bin/clang-12.0.0+0x20ef3e)
clang-12.0: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
clang version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-12.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12.0: note: diagnostic msg: /mnt/baranem/54-14622c.cpp
clang-12.0: note: diagnostic msg: /mnt/baranem/54-14622c.sh
clang-12.0: note: diagnostic msg:

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

with `clang++-12` being:

```
clang++-12 --version
clang version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

Please let me know if I can provide any further information.</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>