| Issue |
56481
|
| Summary |
Invalid ambiguous overload with _simple-requirement_ on a closure
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
JohelEGP
|
See https://godbolt.org/z/P1acGEh6K.
```C++
template<class...> struct unit { };
template<class T> concept unit_type =
#if 1
requires { [](unit<>) {}(T{}); };
#else // Fixes Clang.
requires(void (f)(unit<>)) { f(T{}); };
#endif
template<class> concept unit_prefix = true;
template<class> concept unit_suffix = true;
template<unit_prefix, unit_type> struct prefixed_unit { };
template<unit_type, unit_suffix> struct suffixed_unit { };
template<unit_prefix L, unit_type R> prefixed_unit<L, R> operator*(L, R) { return {}; }
template<unit_type L, unit_suffix R> suffixed_unit<L, R> operator*(L, R) { return {}; }
struct square { };
struct metre : unit<> { };
// static_assert(not unit_type<square>); // Fixes Clang.
auto sqm = square() * metre{};
```
```
<source>:22:21: error: use of overloaded operator '*' is ambiguous (with operand types 'square' and 'metre')
auto sqm = square() * metre{};
~~~~~~~~ ^ ~~~~~~~
<source>:16:58: note: candidate function [with L = square, R = metre]
template<unit_prefix L, unit_type R> prefixed_unit<L, R> operator*(L, R) { return {}; }
^
<source>:17:58: note: candidate function [with L = square, R = metre]
template<unit_type L, unit_suffix R> suffixed_unit<L, R> operator*(L, R) { return {}; }
^
1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs