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

    <tr>
        <th>Summary</th>
        <td>
            Stack dump when namespace qualifier appears in concept auto function parameter.
        </td>
    </tr>

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

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

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

<pre>
    Apologies for the apparent duplicate, accidentally hit enter in the title the first time.

# Report
I've run into a strange compiler error under a specific usage of the new C++20 "concept + auto" syntax for declaring function parameters. Here is a minimal main file to reproduce the error:
~~~{cpp}
#include <concepts>

namespace ns {

template <typename X>
struct S { X x; };

} // namespace ns

template <typename T, template <typename...> typename M>
struct is_match : std::false_type {};

template <typename... X, template <typename...> typename M>
struct is_match<M<X...>, M> : std::true_type {};

template <typename T, template <typename...> typename M>
concept match = is_match<T, M>::value;

constexpr auto foo(match<ns::S> auto f) { // Crash!
  return f;
}

int main() { return 0; }
~~~

Upon compiling with `clang++ -std=c++20 main.cpp` (version 15.0.6) I get the following stack dump:
~~~
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: /home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/grady/git/mgradysaunders/Precept -resource-dir /home/grady/git/llvm/llvm-project/llvm/build/lib/clang/15.0.6 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /home/grady/git/llvm/llvm-project/llvm/build/lib/clang/15.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/grady/git/mgradysaunders/Precept -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug-e52f48.o -x c++ bug.cpp
1.      bug.cpp:21:39: current parser token ')'
 #0 0x00005639f1fa7355 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00005639f1fa4ae4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2a1e9e3520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00005639f1eec015 llvm::FoldingSetBase::InsertNode(llvm::FoldingSetBase::Node*, void*, llvm::FoldingSetBase::FoldingSetInfo const&) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x36bb015)
 #4 0x00005639f4834475 clang::ASTContext::getAutoTypeInternal(clang::QualType, clang::AutoTypeKeyword, bool, bool, clang::ConceptDecl*, llvm::ArrayRef<clang::TemplateArgument>, bool) const (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x6003475)
 #5 0x00005639f4834724 clang::ASTContext::getAutoType(clang::QualType, clang::AutoTypeKeyword, bool, bool, clang::ConceptDecl*, llvm::ArrayRef<clang::TemplateArgument>) const (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x6003724)
 #6 0x00005639f4691378 GetDeclSpecTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::TypeSourceInfo*&) (.constprop.0) SemaType.cpp:0:0
 #7 0x00005639f469b728 clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x5e6a728)
 #8 0x00005639f3f678aa clang::Sema::ActOnParamDeclarator(clang::Scope*, clang::Declarator&) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x57368aa)
 #9 0x00005639f3ccfa45 clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&) (.part.0) ParseDecl.cpp:0:0
#10 0x00005639f3cd19f7 clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x54a09f7)
#11 0x00005639f3cd33ea clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x54a23ea)
#12 0x00005639f3ccc63c clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x549b63c)
#13 0x00005639f3dc3a55 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x5592a55)
#14 0x00005639f3cc89b2 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x54979b2)
#15 0x00005639f3c98530 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#16 0x00005639f3c9f667 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x546e667)
#17 0x00005639f3ca0781 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x546f781)
#18 0x00005639f3c9184a clang::ParseAST(clang::Sema&, bool, bool) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x546084a)
#19 0x00005639f2a5b069 clang::FrontendAction::Execute() (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x422a069)
#20 0x00005639f29e8671 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x41b7671)
#21 0x00005639f2b16270 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x42e5270)
#22 0x00005639ef961185 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x1130185)
#23 0x00005639ef95a3dc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#24 0x00005639ef95cbe5 clang_main(int, char**) (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x112bbe5)
#25 0x00007f2a1e9cad90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#26 0x00007f2a1e9cae40 call_init ./csu/../csu/libc-start.c:128:20
#27 0x00007f2a1e9cae40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#28 0x00005639ef959eb5 _start (/home/grady/git/llvm/llvm-project/llvm/build/bin/clang-15+0x1128eb5)
clang-15: error: unable to execute command: Segmentation fault (core dumped)
clang-15: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 15.0.6 (https://github.com/llvm/llvm-project 088f33605d8a61ff519c580a71b1dd57d16a03f8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/grady/git/llvm/llvm-project/llvm/build/bin
clang-15: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-15: note: diagnostic msg: /tmp/bug-f3b82f.cpp
clang-15: note: diagnostic msg: /tmp/bug-f3b82f.sh
clang-15: note: diagnostic msg: 

********************
~~~

Here are the requested files: [bug-f3b82f.zip](https://github.com/llvm/llvm-project/files/10200883/bug-f3b82f.zip)

## Remarks
I originally hit this error with `clang++-14` as distributed on Ubuntu 22.04. Realizing that was kind of old, I pulled the llvm repo and built the most recent tagged release, apparently 15.0.6, and found that the error persists. I'm in the process of rebuilding under the current state of 16.x on the main branch, but that is going to take a little while to finish. If I find that the issue has been fixed in 16.x, I'll say so here and close the issue.

Interestingly, there is no crash if I move `S` out of `ns` so that the function in question reads `constexpr auto foo(match<S> auto f)`. So it would seem that the issue has something to do with the presence of the namespace qualifier.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWllz4za2_jXsl1NUkaC46MEPsmV1XLcz7dvyTPLmAsFDCmMQYADQyzzkt98CSC2UZSfptKduVbdMgsBZPpwFy6HG8EYiXgTpZZCuPtHebpW-aBtNqxdDe1mhNp9KVb1cLDslVMPRQK002C0C7TqqUVqo-k5wRi0G5AooY7xCaakQL7DlFlBa1MClH2O5Feifaq6NBctbnAXRKoiW4y9J4Bt2Stvh_SYg-SOC7iVwaRVQMFZT2SAw1XZcoAbUWmnwsrrPHTJecwa9oQ2Cqj03iU9wFZDLgFySCAJCmJIMOwsBuQTaWxUQAuZFWvrs9auQCaq5bKDuJbNcSeiopi1a1GYGP6FG4AYotFzylgpoKZdQc6ecAo2dVlXPBk29fEEyKvj7778H-SXruiBf7VXmkom-QgiSq1EwEyTXx7hI2qLpKE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