https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113064
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> --- (In reply to m.cencora from comment #4) > This also might be a just another symptom of the same root cause: > > struct bar > { > bar() = default; > > bar(const bar&); > bar(bar&&); > > bar& operator=(const bar&); > bar& operator=(bar&&); > }; > > struct foo > { > operator const bar& () const &; > > operator bar& () &; > > operator bar&&() &&; > }; > > void test() > { > bar a = foo{}; // ok > > a = foo{}; // not ok - ambiguous call, but why? &&-qualified looks like > a better match > > foo f; > a = f; // ok > > a = static_cast<const foo&>(foo{}); // ok > } Here the error showed up in r9-6486: commit c7e936dbc7f59ad09c28ef57e5399a4256061747 Author: Jason Merrill <ja...@redhat.com> Date: Mon Mar 11 23:19:22 2019 -0400 PR c++/86521 - wrong overload resolution with ref-qualifiers. Here we were wrongly treating binding a const lvalue ref to an xvalue as direct binding, which is wrong under [dcl.init.ref] and [over.match.ref].