<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/156145>156145</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][temp.explicit] Explicit template instantiation leads to incorrect checking of constraints
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ddvamp
</td>
</tr>
</table>
<pre>
Clang trunk (godbolt.org)
template <typename T>
struct S {
void foo() requires (sizeof(T) == 1); // declaration
};
struct I;
template struct S<I>; // explicit
S<I> s;
struct I {};
template <typename T>
void S<T>::foo() requires (sizeof(T) == 1) { // definition
static_assert(sizeof(T) == 2);
}
void fn() {
S<I>{}.foo(); // CE: constraints not satisfied (ill-formed, incomplete type)
}
It looks like the constraints are checked at the point of declaration, not definition. Correct me please if this behavior is determined by the standard
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk82O6zYMhZ9G3hATKFLsJAsv8nMDzLp3X8gWHbMjS65EB50-fSHHSWZQtMBd-UfQ4TkfSZMSXT1iLcqjKM-FmbgPsbb2ZoaxaIL9rE_O-CtwnPwHCLW7BtsEx6sQr0LthTwIeWAcRmcYQegTf47ozYDwU-gfQh4Sx6ll-A3E9ijkAeAWyEIXglA7ofYQ8c-JIqasnehvDJ1Qu5_5ROiz0GdY5zL6CEJdhLqAxdaZaJiCz8W3Z6GPdxdLpffnj6ethwehT-_Z1UsN_xodtcRCHh6nkP6lOHv_Uun_8s7xstb8rQ9CH34xbK72StuRpyUsJDZM7e8mJYz8XxLqzmuBM_u9I_eLiUcj4AVkjrd6-vwC6JQzQBt84mjIcwIfGJJhSh2hzUHIubcuxAGtUCcg34ZhdMgIGc0yIw8n7wwuhI8Ejj4QuMdv0iYitD22H2jB8Hw8BvIMofvWd3WaXbzgrOAUYsSWYUAYHZqEQB1wTwka7M2NQgRKYJExDuTRQvM56yc23ppoC1tru9d7U2C93pZVqbWqZNHXal122KA0m21lK7NRSqPU7bbdN1vdqLKgWklVyp2Wsiw3Sq42bbNbW10ZjeuqklpsJA6G3Mq525D3pqCUJqzXZbXelIUzDbo0L6BSbV42oVTexVjnC2_NdE1iIx0lTi8JJnbz1t5vlGdRHvNYrp4TXZ7hx_IOz4ElnwMzzRzBobEJOMxNu_Ob8ZO_ZuRfWlNM0dU985jySM-jcSXup2bVhkGoS_a1PN7GGP7AloW6zDmTUJcl6q1W_wQAAP__SDRgzg">