Skip to content

[clang] Crash in release mode and assertion fail in build with asserts when compiling for Windows with -std=c++17 #144081

Open
@Fznamznon

Description

@Fznamznon

Code

struct a { int j; };
template<int a::* i> void g_() { }
void bar() {
  g_< (int a::*)0 >();
}

Additional options required: -target x86_64-windows -std=c++17

godbolt demo https://godbolt.org/z/GcMGcW4PE

Seems like clang 21 regression.

Triage notes:

  1. The assertion message is:
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/MicrosoftCXXABI.cpp:234: clang::MSInheritanceModel clang::CXXRecordDecl::getMSInheritanceModel() const: Assertion `IA && "Expected MSInheritanceAttr on the CXXRecordDecl!"' failed.

Seems MSInheritanceAttr is missing.

  1. The attribute is added in assignInheritanceModel function defined in SemaType.cpp if the sample is compiled in C++14 mode. We never enter it when compiling in C++17 mode. The codepath to assignInheritanceModel leads through Sema::CheckTemplateArgument and then CheckTemplateArgumentPointerToMember. In C++17 mode we exit from Sema::CheckTemplateArgument earlier and never call assignInheritanceModel

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions