[Bug c++/102691] New: rvalue reference overload in not preferred over lvalue reference
fchelnokov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 11 21:22:02 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102691
Bug ID: 102691
Summary: rvalue reference overload in not preferred over lvalue
reference
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This code is valid:
```
struct Foo {};
struct Bar {};
constexpr int Baz(const Foo&) { return 0; }
constexpr int Baz(Bar&&) { return 1; }
int main()
{
static_assert( Baz({}) == 1 );
}
```
Here Baz(Bar&&) must be preferred according to [over.ics.rank]/(3.2), as Clang
does.
Unfortunately, GCC wrongly prints ambiguity error, demo:
https://gcc.godbolt.org/z/7Yq8hdcso
Related discussion: https://stackoverflow.com/q/62599846/7325599
More information about the Gcc-bugs
mailing list