https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98987
Bug ID: 98987
Summary: Concept subsumption doesn't work with by-value vs.
by-reference parameters
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david at doublewise dot net
Target Milestone: ---
The following translation unit
```
template<typename T>
concept A = true;
template<typename T>
concept B = A<T> and true;
constexpr bool f(A auto) {
return false;
}
constexpr bool f(B auto const &) {
return true;
}
static_assert(f(0));
```
should compile successfully. Instead, gcc reports
```
<source>:15:18: error: call of overloaded 'f(int)' is ambiguous
15 | static_assert(f(0));
| ^
<source>:7:16: note: candidate: 'constexpr bool f(auto:1) [with auto:1 = int]'
7 | constexpr bool f(A auto) {
| ^
<source>:11:16: note: candidate: 'constexpr bool f(const auto:2&) [with auto:2
= int]'
11 | constexpr bool f(B auto const &) {
| ^
Compiler returned: 1
```
Changing the first `f` overload to accept `A auto const &` or changing the
second to accept `B auto` resolves the ambiguity error.
See it live: https://godbolt.org/z/9aYo64