[Bug c++/65869] Incorrect overload resolution in function return statement

botond at mozilla dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 24 06:57:00 GMT 2015


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

--- Comment #2 from Botond Ballo <botond at mozilla dot com> ---
(In reply to Marc Glisse from comment #1)
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579

I don't think the resolution of this issue affects the validity of my code
example, i.e. it remains invalid.

The resolution of this issue makes the following code valid:

  Derived foo() {
    Base result;
    return result;
  }

(because it allows [class.copy] p32 to apply at all, where previously it didn't
apply because the type of the object to be copied, Base, was different from the
return type of the function Derived).

In my example, however:

  Derived foo() {
    Derived result;
    return result;
  }

p32 already applies, with or without the added wording. The problem is wording
further down in the paragraph which prevents the 'Derived(Base&&)' constructor
from being selected in the first overload resolution when the type of the
object is Derived.



More information about the Gcc-bugs mailing list