<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 - clang crash in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)"
   href="https://bugs.llvm.org/show_bug.cgi?id=45964">45964</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crash in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.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>robert@debian.org
          </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>Created <span class=""><a href="attachment.cgi?id=23501" name="attach_23501" title="crash-89a527.cpp and crash-89a527.sh files">attachment 23501</a> <a href="attachment.cgi?id=23501&action=edit" title="crash-89a527.cpp and crash-89a527.sh files">[details]</a></span>
crash-89a527.cpp and crash-89a527.sh files

The following code:

struct A {
  using B = void (*)();
  B c;
};
class D {
  static const A e[];
};
class F {
public:
  struct G {
    unsigned h[2];
  };
  template <typename I> I get();
};
template <int> void j();
template <typename = void> struct K;
template <> struct K<> {
  template <int l> static void m() {
    F n;
    auto o = n.get<F::G>();
    auto [p, q] = o.h;
    j<l>();
  }
};
const A D::e[]{K<>::m<0>};

makes clang to crash with:

Stack dump:
0.      Program arguments: clang++-10 --std=c++17 -c crash.cpp 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      crash.cpp:18:32: Generating code for declaration 'K<void>::m'
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x7f00a985890f]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7f00a9856bc0]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15CleanupOnSignalEm+0xdd)[0x7f00a985805d]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(+0x9b43f0)[0x7f00a97aa3f0]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14110)[0x7f00b016a110]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0x16388d9)[0x7f00aebc98d9]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction14EmitScalarExprEPKNS_4ExprEb+0x4f)[0x7f00aebba8af]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction11EmitAnyExprEPKNS_4ExprENS0_12AggValueSlotEb+0x38)[0x7f00aeb79e98]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction15EmitIgnoredExprEPKNS_4ExprE+0x59)[0x7f00aeb79e49]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction8EmitStmtEPKNS_4StmtEN4llvm8ArrayRefIPKNS_4AttrEEE+0x194)[0x7f00aecadb14]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction28EmitCompoundStmtWithoutScopeERKNS_12CompoundStmtEbNS0_12AggValueSlotE+0x8c)[0x7f00aecb784c]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction16EmitFunctionBodyEPKNS_4StmtE+0x112)[0x7f00aecf91b2]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen15CodeGenFunction12GenerateCodeENS_10GlobalDeclEPN4llvm8FunctionERKNS0_14CGFunctionInfoE+0x2cf)[0x7f00aecf9a0f]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen13CodeGenModule28EmitGlobalFunctionDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x14d)[0x7f00aed1124d]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen13CodeGenModule20EmitGlobalDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x1d3)[0x7f00aed0b3e3]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen13CodeGenModule12EmitDeferredEv+0x91)[0x7f00aed02501]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen13CodeGenModule12EmitDeferredEv+0xad)[0x7f00aed0251d]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7CodeGen13CodeGenModule7ReleaseEv+0x17)[0x7f00aed01887]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0x17f2434)[0x7f00aed83434]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0x17600ad)[0x7f00aecf10ad]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang8ParseASTERNS_4SemaEbb+0x283)[0x7f00adedf163]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang14FrontendAction7ExecuteEv+0x48)[0x7f00af3553a8]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x621)[0x7f00af30ddf1]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x66f)[0x7f00af3b92ff]
clang++-10(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x98d)[0x412e3d]
clang++-10[0x411151]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0x1acde42)[0x7f00af05ee42]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xd7)[0x7f00a97aa1f7]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x13f)[0x7f00af05e37f]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x2df)[0x7f00af036a7f]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x7a)[0x7f00af036c2a]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0xdc)[0x7f00af049e8c]
clang++-10(main+0x259f)[0x410bcf]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f00a892be0b]
clang++-10(_start+0x2a)[0x40e36a]
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0-4 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 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.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/user/1000/crash-89a527.cpp
clang: note: diagnostic msg: /tmp/user/1000/crash-89a527.sh
clang: 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>