<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144081>144081</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Crash in release mode and assertion fail in build with asserts when compiling for Windows with -std=c++17
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
regression
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fznamznon
</td>
</tr>
</table>
<pre>
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.
2. 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 though `Sema::CheckTemplateArgument` and then `CheckTemplateArgumentPointerToMember`. In C++17 mode we exit from `Sema::CheckTemplateArgument` earlier and never call `assignInheritanceModel`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVEFv2zoT_DX0ZRGDomRZPugg21GRQ4Dii4HmVlDkSmJLkfpIKmnz6x8oKU3iPBQP0MEmd2dndrnDvVedQSzJ7kh25w2fQm9dWb8YPrwYazaNlb_Lk5VIaBW_nK4frXxwkwjAgeyPoEyAHyQ9AtmfSXoktAo4jJoHJOkpXnKSVvFjFSiS3sKTVRK674QVhB1miJhJq_m84e7tgtAKYmR6AsKKj1iEHSiQ9HaJXgovOIRWlZQqKGu4BjvGHx4c_n9SDiVJK7gJ3HUY4FeRf8-zm2dlp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