<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73621>73621</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion failure in C++17 mode in `TreeTransform<Derived>::TransformExceptionSpec`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wjristow
</td>
</tr>
</table>
<pre>
This is spun off from https://github.com/llvm/llvm-project/issues/68543
That issue is marked as fixed by 9f3e3405603177c46b873fa219624b759e6ef851, but actually that commit fixes a reduced test-case attached to that ticket, but not the original test-case. FTR, with a non-assertion compiler, the original test-case and the reduced test-case both compile without crashing. Also, the reduced test-case hits a slightly different assertion than the original full test-case. Both test-cases fail in llvm17, so for comparison of the assertion failures, here are the two assertion-failures with llvm17:
Original (full) test-case assertion failure on llvm17 (equivalent failure still happens on trunk) https://godbolt.org/z/hcf49cTWr
```
/root/llvm-project/clang/lib/Sema/TreeTransform.h:6168:
bool clang::TreeTransform<Derived>::TransformExceptionSpec(clang::SourceLocation, clang::FunctionProtoType::ExceptionSpecInfo&, llvm::SmallVectorImpl<clang::QualType>&, bool&)
[with Derived = {anonymous}::SubstituteDeducedTypeTransform]:
Assertion `ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated' failed.
```
Reduced test-case assertion failure on llvm17 (passes with trunk because fixed by 9f3e3405603177c46b873fa219624b759e6ef851) https://godbolt.org/z/dWa1KMzo1
```
/root/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2667:
bool clang::Sema::SubstExceptionSpec(clang::SourceLocation, clang::FunctionProtoType::ExceptionSpecInfo&, llvm::SmallVectorImpl<clang::QualType>&, const clang::MultiLevelTemplateArgumentList&):
Assertion `ESI.Type != EST_Uninstantiated' failed.
```
For reference, here is the reduced test-case that was fixed by the commit noted above:
```c++
template <class> struct c {
template <class> void bar() noexcept(0);
};
void (c<int>::*tmp)() = &c<int>::bar<int>;
```
The original text-case (shown below) is still failing with the following assertion failure (equivalent to the failure for it noted above from llvm17):
```
/root/llvm-project/clang/lib/Sema/TreeTransform.h:6187:
bool clang::TreeTransform<Derived>::TransformExceptionSpec(clang::SourceLocation, clang::FunctionProtoType::ExceptionSpecInfo&, llvm::SmallVectorImpl<clang::QualType>&, bool&)
[with Derived = {anonymous}::SubstituteDeducedTypeTransform]:
Assertion `ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated' failed.
```
Test-case still failing in trunk https://godbolt.org/z/z4EWrvo35
```c++
namespace a {
inline namespace c {
template <class e> constexpr bool f = __is_member_object_pointer(e);
struct g {
template <class h, class... i>
static auto ae(h p1, i... j) -> decltype(p1(j...));
};
template <class h, class k = h, bool = f<k>> struct l;
template <class h, class k> struct l<h, k, false> : g {};
template <class h, class m, class... r>
auto ag(h p1, m j, r... o) -> decltype(l<h>::ae(p1, j, o...));
struct ai {
template <class m, class n> auto operator()(m p1, n j) -> decltype(p1 > j);
};
template <class e, e...> struct q {};
template <class e, e as> using at = __make_integer_seq<q, e, as>;
template <long... au> using av = q<unsigned long, au...>;
template <long as> using aw = at<unsigned long, as>;
template <class... i> using ax = aw<sizeof...(i)>;
int bg;
struct t {
template <class bo, class... p>
static auto ae(bo p1, p... j) -> decltype(ag(p1, j...));
};
template <class bq, unsigned long... br, class bs, class bt, class bl>
auto bu(bq, av<br...>, bs o, bt, bl) -> decltype(bq ::ae(o, br...));
template <class, class, class... i> class bw {
using bx = ax<i...>;
int ca;
public:
template <class...> auto operator()() noexcept(noexcept(ca)) {
ai s;
return bu(t{}, bx{}, s, ca, bg);
}
};
template <class bo, class... i> bw<int, bo, i...> bind(bo, i...);
} // namespace c
} // namespace a
struct F {
template <typename b,
typename = decltype(static_cast<bool (b::*)()>(&b::operator()))>
F(b *);
};
int cb;
a::bw cc = bind(a::ai(), 0, cb);
F d() { return &cc; }
```
As a side note, there is also a "Reduced slightly" test-case in that original GitHub issue. But that test-case gets a user-error when compiled with a non-checking compiler (i.e., invalid C++). So I'm not including it here. (The original test-case shown above compiles without an error using a non-assertion compiler.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWM1y47gRfhr40mUWCeqHOuggy1Yyld1KslYyRxdIgiLGIMABQMmep081SEqkfuypqT3sIS6XLAON7sbXX3cDYNaKneJ8SaYPZPp4xxpXarM8fDPCOn24S3X-vtyWwoKwYOtGgS4KKIyuoHSutiReEbohdLMTrmzSINMVoRsp9_2f-9robzxzhG6EtQ23hG5myXQSk_CRhKv2c1syB34azVTMvPIcmIVCvPEc0ndYFDGPJ-F0FsbRfJ5NZmkyjwtGo8WMTtL5dMFnvEimEaFrSBsHLHMNk_IdHGrOdFUJ57VZYGB43mQ8B8etu8-Y5cCcY1mJQ7pd4UT2yl2vTWkHruSgjdgJxeRpZQCw2f6BcgfhSmCgtLpn1nLjhFZouBaSGxS4rgCYyv3UpVOpdmWvwavXjYPMMFsKtQsAVtLqXvHl6lI43KuVYlc6-Q65KApuuHJwcs-VTI39Kho53t0DOnEcsFAwIUEowNBGczRvNRTaeEeZEVYjQ7zSkx1c1BgM_RpKbjgww72IO-iT2H0v1mLZWYhXQ6L8s3eU0AR9JXQxxPLcIujeU1zAvzdizyRi0M9bJ6SEktU1VxalnWnUK2o9Y7fOUy1doM2O0M0PQjdlVkwW2far6dybhd1v-y_dGK3dZQ5kkilUIUVK6OaZV4zQzdZwvjVM2UKbKihJvJpFs-S4dUi1ltCujFckXo3kSbx-5EbseU7ip36-m3t6y3iNgDzXPCM0Geh41o3J-G86YziPkRlMbhqV4fC_jHZ6-17zdnik7osqNKEzXOnTvdVaMSn_yzOnzZeqliReD7T-u2GyVfbULcSN-a-LbqdApg8--t2WgMSPQOYPTGn1XunGkvljZ6lJrROucfyx5T5qPoEyfTzBB6sjL8gsfHr-EqAsEBqh9qfn7ct_lFDWMeUEc2gUXZrBdUm-Z7JBMULnnkc8D65zwH_-cVlsPmZpjfNdDng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