[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2023-04-27 Thread ph3rin at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Yunrui Wang  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Yunrui Wang  ---
Issue has been resolved in gcc 12.1.

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2023-04-27 Thread arthur.j.odwyer at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Arthur O'Dwyer  changed:

   What|Removed |Added

 CC||arthur.j.odwyer at gmail dot 
com

--- Comment #7 from Arthur O'Dwyer  ---
According to godbolt.org, Bug 93929, Bug 108594, and this Bug 93106 all appear
to be fixed now (failed in GCC 12, correct behavior in GCC 13.1).

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2023-01-30 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Jonathan Wakely  changed:

   What|Removed |Added

 CC||dev at gutoehrlein dot eu

--- Comment #6 from Jonathan Wakely  ---
*** Bug 108594 has been marked as a duplicate of this bug. ***

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-02-25 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Jonathan Wakely  changed:

   What|Removed |Added

 CC||barry.revzin at gmail dot com

--- Comment #5 from Jonathan Wakely  ---
*** Bug 93929 has been marked as a duplicate of this bug. ***

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek  ---
(In reply to Jason Merrill from comment #3)
> Confirmed.  check_return_expr can't use convert_for_initialization to test
> whether to treat the returned lvalue as an rvalue.

Indeed: convert_for_initialization -> perform_implicit_conversion_flags ->
convert_like_real will build_temp for the rvalue version of OBJ, so it calls
build_special_member_call -> build_new_method_call_1.

Here we have three candidates:

  X::X(X&&)
  constexpr X::X(const X&)
  constexpr X::X()

the last one is not viable so splice_viable kills it.  And tourney selects

  X::X(X&&)

as expected.  But we pass it to build_over_call and that will not complain and
just return error_mark_node for a DECL_DELETED_FN function.  Then the second
stage of the two-stage overload resolution succeeds.  I guess we need to stop
and issue an error when we found a move ctor, but it's deleted (but not if we
don't find a move ctor at all).

(Came here in the context of PR91212 where this convert_for_initialization
selects the wrong overload.)

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-01-06 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

--- Comment #3 from Jason Merrill  ---
Confirmed.  check_return_expr can't use convert_for_initialization to test
whether to treat the returned lvalue as an rvalue.

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-01-06 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Jason Merrill  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-01-06
 CC||jason at gcc dot gnu.org
 Ever confirmed|0   |1

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-01-03 Thread ph3rin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

--- Comment #2 from Yunrui Wang  ---
(In reply to Jakub Jelinek from comment #1)
> What you cite doesn't say anything that would make the testcase invalid.
> The standard says that for an implicitly movable entity seen in return
> statement shall first perform overload resolution for the copy constructor
> as if it was an rvalue, which in this case fails because the move ctor is
> deleted.  And in that case, another overload resolution is performed, this
> time considering the implicitly movable entity as lvalue, and that succeeds.
> So, if copy-ellision wouldn't be performed,
> not_movable::not_movable(not_movable const&) would be invoked, but in this
> case copy-ellision is invoked and thus it is default constructed into the
> return value object in the caller.

The first overload resolution should succeed by selecting the deleted move
constructors. Deleted functions are defined and are considered for overload
resolution (unless otherwise specified - there are some edge cases, but not in
this example).

[Bug c++/93106] [c++2a] Deleted move constructor is not selected when returning an automatic variable

2020-01-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
What you cite doesn't say anything that would make the testcase invalid.
The standard says that for an implicitly movable entity seen in return
statement shall first perform overload resolution for the copy constructor as
if it was an rvalue, which in this case fails because the move ctor is deleted.
 And in that case, another overload resolution is performed, this time
considering the implicitly movable entity as lvalue, and that succeeds.  So, if
copy-ellision wouldn't be performed, not_movable::not_movable(not_movable
const&) would be invoked, but in this case copy-ellision is invoked and thus it
is default constructed into the return value object in the caller.