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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] crashes on invalid code 
        </td>
    </tr>

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

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

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

<pre>
    Input:
```
typedef mbstate_t;
  template < typename , typename , typename >
  class a
  class b {
    namespace {
    template < typename c > b::operator=() {
      struct :a< c, char, stdmbstate_t > d
```

Crashes when compiled with clang-trunk.

```
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <eof> parser at end of file
2.      <source>:5:5: parsing namespace '(anonymous)'
3.      <source>:6:44: parsing function body
4.      <source>:6:44: in compound statement ('{}')
 #0 0x0000000003563048 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3563048)
 #1 0x0000000003561194 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3561194)
 #2 0x00000000034af278 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f5cfba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000000000635e3c1 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x635e3c1)
 #5 0x00000000060095f4 BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*, ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool, clang::CXXCtorInitializer*&) SemaDeclCXX.cpp:0:0
 #6 0x000000000605016e clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool, llvm::ArrayRef<clang::CXXCtorInitializer*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x605016e)
 #7 0x00000000060990fd clang::Sema::DefineImplicitDefaultConstructor(clang::SourceLocation, clang::CXXConstructorDecl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60990fd)
 #8 0x0000000005d5b991 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d5b991)
 #9 0x00000000063405ff PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0
#10 0x000000000635fce0 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x635fce0)
#11 0x0000000005f71444 clang::Sema::ActOnUninitializedDecl(clang::Decl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f71444)
#12 0x0000000005c2a245 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c2a245)
#13 0x0000000005c3eff0 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c3eff0)
#14 0x0000000005c403d2 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c403d2)
#15 0x0000000005c408df clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c408df)
#16 0x0000000005cee384 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5cee384)
#17 0x0000000005cef0f8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5cef0f8)
#18 0x0000000005cefef9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5cefef9)
#19 0x0000000005cf0a6a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5cf0a6a)
#20 0x0000000005c05d48 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c05d48)
#21 0x0000000005d0cb07 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d0cb07)
#22 0x0000000005d1453a clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d1453a)
#23 0x0000000005d147e3 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d147e3)
#24 0x0000000005c40a60 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c40a60)
#25 0x0000000005c08297 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c08297)
#26 0x0000000005c57324 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c57324)
#27 0x0000000005c5c3d9 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c5c3d9)
#28 0x0000000005c40ab2 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c40ab2)
#29 0x0000000005c08297 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c08297)
#30 0x0000000005c09de7 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5c09de7)
#31 0x0000000005bf93ca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5bf93ca)
#32 0x0000000003d9e2e5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d9e2e5)
#33 0x0000000004024e21 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4024e21)
#34 0x0000000003fa218b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fa218b)
#35 0x00000000041046f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41046f3)
#36 0x0000000000c192c6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc192c6)
#37 0x0000000000c11cdd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x0000000003de52b9 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
#39 0x00000000034af6a3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x34af6a3)
#40 0x0000000003de54d9 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
#41 0x0000000003dad8d7 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dad8d7)
#42 0x0000000003dae28d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dae28d)
#43 0x0000000003db7fdc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3db7fdc)
#44 0x0000000000c16601 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc16601)
#45 0x0000000000b0f494 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xb0f494)
#46 0x00007f5cfba29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#47 0x00007f5cfba29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#48 0x0000000000c114de _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc114de)
```
godbolt: https://godbolt.org/z/K9jMo3c3x
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW1132zbS_jX0DY58SICkyAtfyHLU1236Jhtlt7nTAQFQQkMCLAg6cn_9HoCURFCU7GSZbve0PU0ikcDMM88MBoMP4brmW8HYnRfde9HDDW70Tqq7nBV8H4fwJpP0-e5RVI320MLzHzx_4cV-97_9qp8rRlkOyqzWWLON9tB9-wYAzcqqwJoBDy2BaShwyYAHL35Bbw5dSYHrGmD3awa8-VE4AKZPXWHC3MfjWomRDjJjBlrIiimspfLQgwcTD6auBABqrRqigYcW2EghBibZYWX-rTU9GmuF0lFi2r-XCtc7VoMvOyYAkWXFC0bBF653xiaxnWnViM-3_S4DOWuNyWdAm7I6usC_9fz0vZJbhUuA1bYpmdC1hxbAgytZaQ-uOlVqxvZVIRVT5tlJoQdXGReHZx689-A9mG3pF6zyWQhmWzCTRhiuKiOy0VWjb2swK4viqQSz2T6JZ7guZ_Wz0HjvoQcuNCvAbA1msy0hMy1lQXaYC8vwFUymcS1wVe-kBrOcyEKqGeV4K2StOanBLBdyRgyLzmMPLWvZKMKOMRMYUjy0ZDI3TqmwqpkCWAMmKJA5yHnB2pawa3kSgBZR98f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