public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98987] New: Concept subsumption doesn't work with by-value vs. by-reference parameters
@ 2021-02-07 21:49 david at doublewise dot net
2021-02-08 13:13 ` [Bug c++/98987] " ppalka at gcc dot gnu.org
2021-02-09 7:18 ` david at doublewise dot net
0 siblings, 2 replies; 3+ messages in thread
From: david at doublewise dot net @ 2021-02-07 21:49 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/98987] Concept subsumption doesn't work with by-value vs. by-reference parameters
2021-02-07 21:49 [Bug c++/98987] New: Concept subsumption doesn't work with by-value vs. by-reference parameters david at doublewise dot net
@ 2021-02-08 13:13 ` ppalka at gcc dot gnu.org
2021-02-09 7:18 ` david at doublewise dot net
1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-02-08 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98987
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
As with PR96333, since the function templates' function parameters aren't
equivalent, neither is considered more constrained than the other, and so we're
correct to reject this testcase from what I understand.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/98987] Concept subsumption doesn't work with by-value vs. by-reference parameters
2021-02-07 21:49 [Bug c++/98987] New: Concept subsumption doesn't work with by-value vs. by-reference parameters david at doublewise dot net
2021-02-08 13:13 ` [Bug c++/98987] " ppalka at gcc dot gnu.org
@ 2021-02-09 7:18 ` david at doublewise dot net
1 sibling, 0 replies; 3+ messages in thread
From: david at doublewise dot net @ 2021-02-09 7:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98987
David Stone <david at doublewise dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |david at doublewise dot net
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from David Stone <david at doublewise dot net> ---
I agree, this is a duplicate of that other issue.
*** This bug has been marked as a duplicate of bug 96333 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-09 7:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 21:49 [Bug c++/98987] New: Concept subsumption doesn't work with by-value vs. by-reference parameters david at doublewise dot net
2021-02-08 13:13 ` [Bug c++/98987] " ppalka at gcc dot gnu.org
2021-02-09 7:18 ` david at doublewise dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).