<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/152958>152958</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][bytecode] Assertion `Val && "isa<> used on a null pointer"' failed
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            crash,
            clang:bytecode
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Reproducer:
https://godbolt.org/z/v9oW3Y4Yo
```cpp
template <typename T>
constexpr bool test() {
  T{}.~T();
  return true;
}

struct S { int x; };
bool t = test<S>();
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = clang::NamedDecl; From = clang::Decl]: Assertion `Val && "isa<> used on a null pointer"' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter <source>
1.      <source>:8:19: current parser token ';'
 #0 0x000000000400b2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x400b2d8)
 #1 0x0000000004008704 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4008704)
 #2 0x0000000003f4d048 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007b239ea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007b239ea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007b239ea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007b239ea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007b239ea2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007b239ea39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000007ae08c6 clang::interp::Destroy(clang::interp::InterpState&, clang::interp::CodePtr, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ae08c6)
#10 0x0000000007b68e98 clang::interp::Interpret(clang::interp::InterpState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b68e98)
#11 0x0000000007b70a5c clang::interp::Call(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Function const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7b70a5c)
#12 0x0000000007e019a8 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCallExpr(clang::CallExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e019a8)
#13 0x0000000007e07170 clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e07170)
#14 0x0000000007dfc502 clang::interp::Compiler<clang::interp::EvalEmitter>::visitVarDecl(clang::VarDecl const*, bool, bool)::'lambda0'(unsigned int)::operator()(unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7dfc502)
#15 0x0000000007dfcaea clang::interp::Compiler<clang::interp::EvalEmitter>::visitVarDecl(clang::VarDecl const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7dfcaea)
#16 0x0000000007dfcf44 clang::interp::Compiler<clang::interp::EvalEmitter>::visitDeclAndReturn(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7dfcf44)
#17 0x00000000079a60a7 clang::interp::EvalEmitter::interpretDecl(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x79a60a7)
#18 0x0000000007987f2d clang::interp::Context::evaluateAsInitializer(clang::interp::State&, clang::VarDecl const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7987f2d)
#19 0x0000000007960913 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7960913)
#20 0x0000000007776db2 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7776db2)
#21 0x0000000007777161 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7777161)
#22 0x0000000006a779ab clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a779ab)
#23 0x0000000006a7f08b clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a7f08b)
#24 0x00000000066e405a clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e405a)
#25 0x00000000066f29a9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66f29a9)
#26 0x00000000066b07ee clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b07ee)
#27 0x00000000066b0f8f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b0f8f)
#28 0x00000000066b8763 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b8763)
#29 0x00000000066b9675 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b9675)
#30 0x00000000066ab87a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66ab87a)
#31 0x00000000049b0d28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49b0d28)
#32 0x0000000004ca5115 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ca5115)
#33 0x0000000004c2144e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c2144e)
#34 0x0000000004d96861 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d96861)
#35 0x0000000000daf00f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaf00f)
#36 0x0000000000da5cba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x0000000004a18669 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
#38 0x0000000003f4d4e4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f4d4e4)
#39 0x0000000004a18c7f 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
#40 0x00000000049daf1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49daf1d)
#41 0x00000000049dbfae 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+++0x49dbfae)
#42 0x00000000049e39f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49e39f5)
#43 0x0000000000dab4c5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdab4c5)
#44 0x0000000000c5f554 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc5f554)
#45 0x00007b239ea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007b239ea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000da5765 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda5765)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWl1z4ygW_TXkhZJLQt8PeVDseLanere72qnemicXkpDDRhZaQGlnHva3bwGSJeQ43dmyU1u7U5kZWcDlnMPlckFgIeiuIeQWhHcgXN3gTj4yfvvkYM7ZD3GTs_Ll9htpOSu7gnDgZ8DNHqVshXpEa4DWO1bmrJYLxncArf8EaP2csr_7fwR_MOBmIHLNX9G2wM0k2bc1lgQCfylfWtLgPYEPwL8HblawRkhyaDnMGauhJEIClACUQhDfATeD8EE9xKvFvx5MAfDNe05kxxsoeUfMKxCv1H_dTEjeFRJulAlIGwkPwL-DqljXMx1B4K9Md_5yo7BMjB_xG3t3uHiSHBfEKDGyY41gNVEsatzsALpTf34GAVpzxiRA67p-3jstZ_8gxfAToDVtiroryfhi07Ut46rGEgtJm93iEfiZ56bKmpBY0sLoo-v7GfAzKvCW7tt6W9TAXz4wgJZQiwnXnO0ByhQnXbNkVGlqFyqBw7sfVD7CB6a1MBx0i7_hPSlXRFm-0y3mFXRZuFLoMiEIl5Q1EETud1xDgCKAIggQogIDfwn8e9gJUkLWQAybrq5hy2gjCQcIARTDCtOalAvgZl8_32ebeyi6fE8lxDDvdpATpQyUDM48kMrHLl8Uis4g40xtKkRHBEBriJsS9qJD-UhgwbF4hPlxXNEStlw5fEGEgipYx81r1RILwQqKJSkh7xooCk5bqfBuJC6eYNntW-MZ7gK46VfOdhzvIea7bk8aKXqPYK3CVLB9S2vCHXJoa8aVCGstrIMHIYUjedc8AbTOaTMUG-eCzq78gXnlBNDZQYcpu7htlfVOtp1cCOjslQrQcQ5J5GCxd8RLI_EB-CuleQ2dqmHOM-E5E0SVQ2cDHWdXFI5krC4eMW2Av3oTr6osGtyKRyahUxWsZtwpKd41TEhaCNOH1nj2mhxawqlSBddOQ3442ilxIx3tEC0nknAVJvoB0CHCU6pa7_wsUdNDz46i45w0EraYC8KhZE-kgQDFaiajWEUKgHwXugd3-C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