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

    <tr>
        <th>Summary</th>
        <td>
            Constrained call operator on lambda variable template causes Assertion `Val && "isa<> used on a null pointer"'
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          davidstone
      </td>
    </tr>
</table>

<pre>
    The following valid translation unit

```
template<typename T>
concept c = true;

template<typename>
auto f = []() requires c<void> {
};

void g() {
        f<int>();
};
```

causes clang to crash with

```
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::DeclContext; 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++2b <source>
1.      <source>:9:9: current parser token ')'
2.      <source>:8:10: parsing function body 'g'
3.      <source>:8:10: in compound statement ('{}')
 #0 0x00005645c47bace4 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00005645c47b8a8c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f6fa8c)
 #2 0x00005645c46efa18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fc740f46420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fc740a1300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fc7409f2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007fc7409f2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007fc740a03fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00005645c6fc57df clang::Sema::CheckFunctionConstraints(clang::FunctionDecl const*, clang::ConstraintSatisfaction&, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x677c7df)
 #9 0x00005645c75967af clang::Sema::AddMethodCandidate(clang::CXXMethodDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, llvm::MutableArrayRef<clang::ImplicitConversionSequence>, clang::OverloadCandidateParamOrder) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4d7af)
#10 0x00005645c759954b clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d5054b)
#11 0x00005645c759a8fe clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d518fe)
#12 0x00005645c726a43a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a2143a)
#13 0x00005645c726f1bb clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a261bb)
#14 0x00005645c6d974e7 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x654e4e7)
#15 0x00005645c6d8f4b7 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65464b7)
#16 0x00005645c6d9242b clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x654942b)
#17 0x00005645c6d924cd clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65494cd)
#18 0x00005645c6d9670d clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x654d70d)
#19 0x00005645c6e1007e clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65c707e)
#20 0x00005645c6e0663a clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65bd63a)
#21 0x00005645c6e07555 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65be555)
#22 0x00005645c6e085ba clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65bf5ba)
#23 0x00005645c6e09eca clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65c0eca)
#24 0x00005645c6d3b191 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64f2191)
#25 0x00005645c6d6ef2f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6525f2f)
#26 0x00005645c6d2fd19 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64e6d19)
#27 0x00005645c6d30570 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#28 0x00005645c6d35d2b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64ecd2b)
#29 0x00005645c6d36bba clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64edbba)
#30 0x00005645c6d2b06a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64e206a)
#31 0x00005645c5ad31a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x528a1a8)
#32 0x00005645c536ce89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b23e89)
#33 0x00005645c52f474e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4aab74e)
#34 0x00005645c5452433 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c09433)
#35 0x00005645c1c6c984 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1423984)
#36 0x00005645c1c65a68 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#37 0x00005645c5163a19 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
#38 0x00005645c46f01ba llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ea71ba)
#39 0x00005645c516426f 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
#40 0x00005645c512eba9 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48e5ba9)
#41 0x00005645c512f62d 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+++0x48e662d)
#42 0x00005645c51390cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48f00cc)
#43 0x00005645c1c6ad63 clang_main(int, char**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1421d63)
#44 0x00007fc7409f4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#45 0x00005645c1c6565e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x141c65e)
clang-16: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

See it live: https://godbolt.org/z/7qWc5z67a
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlW1tT4zoS_jXhRRXK98sDDyEMZ2d3pmAn1Nl5S8mSnHjHsTyyzMD59dst2yQySYA55OxsLRVIYkmt_r5udbdlkUn-eHG3FiSXZSl_FNWK3NOy4EQrWjUl1YWsSFsVeuJcTZxZ_zdy-pf5qsWmhp5i4s_1Yy0quhHkbuJ_6FqZrJioNWFk4l-B2Bb6Xe5K2zP8aTBttSS5GTkJLyfh1cRLJl5KlPjeFko0hMGoe1lwGEEm8SA3vhrNgV3Iqh-87eekOYwvKo0TmsbtuF0ZNt4eF20bVKCkwBloyRRt1uRHoddHqDK9J94lvvwZmXjXSkoNb2V5v5nWSv5bsOErvBUVK1suthcWbV1LhT3mtNFgrfM1yHGdFKU1GszFSCZlSUx_fwavoqHLAhheshKw3smJNydgk0YTmBtkzhC76cklmNlL7EbkK7xEWOROGkN0GMyIK8HKuay0eAAGL82YfV3QbqDfrGmEMg4FfPxOS4AfwQvePFASlEMjAqmcQBdKqrYsSS3BOkJBl4kXk5wWpeDnHZe3nz7MFh9I02abQkP_rF2BXyA9aI611nWDKnjX8FqB_m12zhDTwOWI8qJpWtHAB0IrTnrmiYal0Vk2o-wbLAomkMAaJlKSiQa1bWSruss4kjaNZAX4MyeqrUjDVFHrXuWFBiGEt5saNTOXHGhKb5VcKbohVK3ajah00zuHrFEz0LoG3GoqHupSKmTj2jA8pQOjzRQWVvUNGrKiGpo7PyPTFf9BVT4N4BOZSpRL6xqlt7pu9XlDpgsyna4Ym2pwHbamIMK_Ojo9dm4qWjdrqck0ZxIaprygq0qCWzIQmVdyaoizLzcaluoV61TzMvCWeU_fsORdJMS67M_S_pewVingh9RUAXKw8zcB3uTFuHLhrxHg7RGQmFWCEnAkRrm8rZjxxQwi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