<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Concepts: cannot find matching function when requires clause contains invalid expression"
href="https://bugs.llvm.org/show_bug.cgi?id=46218">46218</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Concepts: cannot find matching function when requires clause contains invalid expression
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>maria.baburina@jetbrains.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Clang cannot find matching function constrained on a concept when its requires
clause has invalid expression but would otherwise evaluate to true. Code
compiles correctly with MSVC 19.27.28826.0 and GCC 10.1 but not Clang 10.
>From <a href="https://en.cppreference.com/w/cpp/language/constraints">https://en.cppreference.com/w/cpp/language/constraints</a>:
The substitution of template arguments into a requires-expression used in a
declaration of a templated entity may result in the formation of invalid types
or expressions in its requirements, or the violation of semantic constraints of
those requirements. In such cases, the requires-expression evaluates to false
and does not cause the program to be ill-formed. The substitution and semantic
constraint checking proceeds in lexical order and stops when a condition that
determines the result of the requires-expression is encountered. If
substitution (if any) and semantic constraint checking succeed, the
requires-expression evaluates to true.
#include <concepts>
struct S {
double value;
};
template <class T>
concept fp_or_value = requires (T x) {
requires std::floating_point<decltype(x.value)> || std::floating_point<T>;
};
template <fp_or_value T>
void test(T x) {}
int main() {
double x = 1.0;
test(x);
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>