<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68885>68885</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
NTTP references in requires clauses
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend,
concepts
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cor3ntin
</td>
</tr>
</table>
<pre>
Clang rejects this code
```cpp
#include <concepts>
template <decltype(auto) a>
struct S {
static constexpr int i = 42;
};
template <decltype(auto) a>
requires true
struct S<a> {
static constexpr int i = 0;
};
static constexpr int a = 0;
void test() {
static_assert(S<a>::i == 0); // Ok
static_assert(S<(a)>::i == 0); // Fails
}
```
https://godbolt.org/z/hsb4c5WE3
Clang picks the primary template when a NTTP is a reference type, even if there is a more constrained specialization.
Other compiler accept this code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMtu2zoQ_ZrRZhBDGlqOtNDCj2h5c4EG6LKgqLHNhiZVkkqbfH1ByYmbwC1awKCF4ZwzZ16UIeiDZW6g3EC5y-QYj843ynlho7ZZ5_rnZmukPaDnr6xiwHjUAZXrGfId5OvzucrnnxqGs4WEtsqMPSOIrXJW8RADiDuc7yOfBiPjdNuzMvF5YKBKjtEB1ShB3M2OIfpRRfyEcLuZLYiIIcqoFSpnQ-Qfg0dtI2oEscMlgTh7wu3u8v1vYT1_G7XngNGP_F4JiK2cEvlLQfkf9FyFyY-w6XxyusfIIQJVSeuV8F9kCOyTw6tIEGsQ60nHzEk1iA0iUAvU4v3jmeIaPtVl8v8dy5mkldqES4LXxuJX4zHGISTGCX1wfedMXDh_AGpfgNpj6Jaq_Hwn8B3VdM6jOGj1mAaRcfD6JP0zvrX1-5EtSvzv4eF_1AElet6zZ6sY51ZvkZ_Yot4nvOfZ6eQ8zz3wUlvuMQystDT6RUbt7GIOfp8QqNxp0IY9SpVG-rIPZ6-sb0Rfi1pm3BSr-rYoypzq7NhwsarzVZGXRdXvK7WUvSjlsi5z6vZlWVWZbignUeQFFZQwi3zflaIrhOjqjoWsYJnzSWqzMObplCqW6RBGblZVVZWZkR2bMG0ykQLaAG0oByKgbbKk0oFY772zkW1_uXjdTaL0BPgmsd904yHAMjc6xHCJF3U03EzVfStsQG3xbV2UkWPgkI3eNB86reNx7BbKnYDaxHj-uxm8S08LUDulE4DaKaOfAQAA___VP14K">