[Bug c++/87109] New: Wrong overload picked with ref-qualifiers

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Aug 26 17:07:00 GMT 2018


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

            Bug ID: 87109
           Summary: Wrong overload picked with ref-qualifiers
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

As discussed in <https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01607.html>, g++
chooses the wrong overload for f1:

#include <utility>

struct C { };
struct A {
  operator C() &;
  operator C() &&;
};

C f1(A a)
{
   return a; // should call operator C()&, but calls operator C()&&
}

C f2(A a)
{
   return std::move(a); // calls operator C()&&
}


More information about the Gcc-bugs mailing list