<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62141>62141</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Class Template Argument Deduction ignores requires clause
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
craffael
</td>
</tr>
</table>
<pre>
### clang version
```
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 27f27d15f6c90b026eca23b8ee238fdbf772fd80)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
```
### Steps to reproduce
Try to compile the following program with `clang++ -std=c++20 source.cc` (see also [godbolt](https://godbolt.org/z/rrvvY84hd))
```
#include <concepts>
template <class DEGREE_FUNCTOR>
class H1HierarchicFeSpace {
public:
static_assert(!std::same_as<DEGREE_FUNCTOR, int>);
// 1
H1HierarchicFeSpace(long d) {}
// 2
H1HierarchicFeSpace(DEGREE_FUNCTOR degree_functor)
requires(!std::convertible_to<DEGREE_FUNCTOR, long>)
{}
};
// Deduction Guides
H1HierarchicFeSpace(long)
-> H1HierarchicFeSpace<long>;
int main() {
auto fes = H1HierarchicFeSpace(2);
}
```
Error Message:
```
<source>:6:17: error: static assertion failed due to requirement '!std::same_as<int, int>'
static_assert(!std::same_as<DEGREE_FUNCTOR, int>);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:20:16: note: in instantiation of template class 'H1HierarchicFeSpace<int>' requested here
auto fes = H1HierarchicFeSpace(2);
^
1 error generated.
```
The same code compiles fine with gcc and MSVC. I think the problem is that clang somehow selects constructor `2)` even though `DEGREE_FUNCTOR=int` fails the requires clause! Correct would be to use the deduction guide (which will then select constructor 1))
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk2P2zYT_jX0ZWBDIq0PH3zw-iPJIe8LJNsCPS0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