https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97801

            Bug ID: 97801
           Summary: overload resolution ambiguity isn't detected when
                    rvalue ref qualifier is involved
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/7onfa6
struct G {
   static int min(int=0) { return 1; }
   int min() && { return 2; }
};
int x = G::min();

GCC accepts; Clang, MSVC, and ICC reject.

GCC treats `G::min()` as an unambiguous call to the static member function.
However, C++ seems to require that overload resolution reject this code as
ambiguous -- it should be ambiguous between the two different G::min()s capable
of taking zero arguments, *even though* the non-static one can't actually be
called without a "this" argument.

Strangely, this bug appears only when the non-static candidate is
rvalue-ref-qualified (either "&&" or "const&&" or "volatile&&"). It does not
appear with "&" or "const&" or "const", nor if the function is not
ref-qualified.
  • [Bug c++/97801] New: overloa... arthur.j.odwyer at gmail dot com via Gcc-bugs

Reply via email to