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

    <tr>
        <th>Summary</th>
        <td>
            Assertion `CXXInfo->BaseOffsets.count(Base) && "Did not find base!"` failed
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++,
            clang:frontend,
            crash-on-invalid
      </td>
    </tr>

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

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

<pre>
    While reducing #63250, I stumbled upon the following crash (https://godbolt.org/z/84b6WTans):
```cpp
template <typename T>
struct _Copy_ctor_base : T {};

template <typename _Types>
struct _Variant_base : _Copy_ctor_base<_Types> {};

struct monostate {};

template <>
struct monostate {};

_Variant_base<monostate> v;
```
Clang 19.0 crash:
```
<source>:9:1: error: extraneous 'template<>' in declaration of struct 'monostate'
    9 | template <>
      | ^
<source>:10:8: error: specialization of member 'monostate' does not specialize an instantiated member
   10 | struct monostate {};
      | ^
<source>:7:8: note: attempt to specialize declaration here
    7 | struct monostate {};
      |        ^
<source>:2:8: error: implicit default constructor for '_Copy_ctor_base<monostate>' must explicitly initialize the base class 'monostate' which does not have a default constructor
    2 | struct _Copy_ctor_base : T {};
      | ^
<source>:5:8: note: in implicit default constructor for '_Copy_ctor_base<monostate>' first required here
    5 | struct _Variant_base : _Copy_ctor_base<_Types> {};
      | ^
<source>:12:26: note: in implicit default constructor for '_Variant_base<monostate>' first required here
   12 | _Variant_base<monostate> v;
      | ^
<source>:7:8: note: 'monostate' declared here
    7 | struct monostate {};
      |        ^

clang++: /root/llvm-project/clang/include/clang/AST/RecordLayout.h:253:
clang::CharUnits clang::ASTRecordLayout::getBaseClassOffset(const clang::CXXRecordDecl*) const:
Assertion `CXXInfo->BaseOffsets.count(Base) && "Did not find base!"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++98 <source>
1.      <source>:12:27: current parser token ';'
 #0 0x0000000003979978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3979978)
 #1 0x000000000397765c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x397765c)
 #2 0x00000000038c9018 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000073bd3f842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000073bd3f8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000073bd3f842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000073bd3f8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000073bd3f82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000073bd3f839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000003e0b6bf clang::ASTRecordLayout::getBaseClassOffset(clang::CXXRecordDecl const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e0b6bf)
#10 0x00000000077d1c8a (anonymous namespace)::EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset((anonymous namespace)::BaseSubobjectInfo const*, clang::CharUnits) RecordLayoutBuilder.cpp:0:0
#11 0x00000000077d1e2e (anonymous namespace)::EmptySubobjectMap::CanPlaceBaseAtOffset((anonymous namespace)::BaseSubobjectInfo const*, clang::CharUnits) RecordLayoutBuilder.cpp:0:0
#12 0x00000000077d212e (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutBase((anonymous namespace)::BaseSubobjectInfo const*) RecordLayoutBuilder.cpp:0:0
#13 0x00000000077d24c1 (anonymous namespace)::ItaniumRecordLayoutBuilder::LayoutNonVirtualBase((anonymous namespace)::BaseSubobjectInfo const*) RecordLayoutBuilder.cpp:0:0
#14 0x00000000077cbcdd clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77cbcdd)
#15 0x00000000072de1a2 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72de1a2)
#16 0x00000000072c6187 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72c6187)
#17 0x00000000072dd257 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x72dd257)
#18 0x00000000064820c3 clang::Sema::CheckArgAlignment(clang::SourceLocation, clang::NamedDecl*, llvm::StringRef, clang::QualType, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64820c3)
#19 0x00000000064ae26a clang::Sema::CheckConstructorCall(clang::FunctionDecl*, clang::QualType, llvm::ArrayRef<clang::Expr const*>, clang::FunctionProtoType const*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64ae26a)
#20 0x00000000066b738c clang::Sema::CompleteConstructorCall(clang::CXXConstructorDecl*, clang::QualType, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, llvm::SmallVectorImpl<clang::Expr*>&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b738c)
#21 0x0000000006a2a3ac 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
#22 0x0000000006a3ede6 clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a3ede6)
#23 0x000000000660ea8b clang::Sema::ActOnUninitializedDecl(clang::Decl*) (.part.0) SemaDecl.cpp:0:0
#24 0x00000000062bd9f4 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62bd9f4)
#25 0x00000000062cdc4a 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+++0x62cdc4a)
#26 0x0000000006289b0e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6289b0e)
#27 0x000000000628a303 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x628a303)
#28 0x0000000006290907 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6290907)
#29 0x00000000062917bf clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62917bf)
#30 0x000000000628527a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x628527a)
#31 0x0000000004246e08 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4246e08)
#32 0x00000000044c8199 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c8199)
#33 0x000000000445025e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x445025e)
#34 0x00000000045aef3e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45aef3e)
#35 0x0000000000c4fdec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4fdec)
#36 0x0000000000c4907a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x000000000428a649 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 0x00000000038c94c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c94c4)
#39 0x000000000428ac3f 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 0x0000000004250fd5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4250fd5)
#41 0x0000000004251a3d 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+++0x4251a3d)
#42 0x00000000042597c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42597c5)
#43 0x0000000000c4d285 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4d285)
#44 0x0000000000b2f354 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2f354)
#45 0x000073bd3f829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x000073bd3f829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000c48b6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc48b6e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkW11zozjW_jXkRmUXCMzHRS5oksybeXums5PMTN-5hBC2NkJiJJFO5tdvSWAbYTsf3XF2tzaVmbaRdPQ8zzk6OiCClKIrTsi5t_jkLS7OUKfXQp5f8ooyxs5KUT2d_7mmjABJqg5TvgIeDOMQLnwPFuAaKN01JSMV6FrBgV4TUAvGxDfTE0uk1sCD6VrrVnlh7sErD16tRFUKpudCrjx49bcHr9KojP-8Q1x5MDPd_AvPz73Y739x2_ZXNGlahjQBXljop5Zw1BBw54WXfbPSssMaLAvRPi2xFnJZImU65-AOeMknL7nwwk-D8eMGl3dPLVF7Vv9AkiKudzYn83hhsR15eLbBUiO4UNrO-hKmKYgXhjoYvbDYdjeQHnadN8L2XwuG-AoE2dzvHbbvgOFrWCjRSWyseWFuHBUYHYiUQtoPj1oiTkSngAeTDY-BBkwA5aAimCGJNBUciBoMtDyY7KDCpJ8OAAAy4CUFOKgIsD-m2VtcHgQY-F6Ypw5C1RJMEaN_bxE0pCmJnCIAlSAKcKF3IwhAHFCuNOKaIk2qYegWTeBbNC956mXcyQ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