[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-30 Thread arsen at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Arsen Arsenović  changed:

   What|Removed |Added

 CC||netcan1996 at gmail dot com

--- Comment #9 from Arsen Arsenović  ---
*** Bug 103358 has been marked as a duplicate of this bug. ***

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

--- Comment #8 from GCC Commits  ---
The releases/gcc-14 branch has been updated by Patrick Palka
:

https://gcc.gnu.org/g:066c7893eae0bfc7d9b33b931f115f455246c914

commit r14-10498-g066c7893eae0bfc7d9b33b931f115f455246c914
Author: Patrick Palka 
Date:   Mon Jul 22 21:30:49 2024 -0400

c++/coroutines: correct passing *this to promise type [PR104981]

When passing *this to the promise type ctor (or to its operator new)
(as per [dcl.fct.def.coroutine]/4), we add an explicit cast to lvalue
reference.  But this is unnecessary since *this is already always an
lvalue.  And doing so means we need to call convert_from_reference
afterward to lower the reference expression to an implicit dereference,
which we're currently neglecting to do and which causes overload
resolution to get confused when computing argument conversions.

So this patch removes this unneeded reference cast when passing *this
to the promise ctor, and removes both the cast and implicit deref when
passing *this to operator new, for consistency.  While we're here, use
cp_build_fold_indirect_ref instead of directly building INDIRECT_REF.

PR c++/104981
PR c++/115550

gcc/cp/ChangeLog:

* coroutines.cc (morph_fn_to_coro): Remove unneeded calls
to convert_to_reference and convert_from_reference when
passing *this.  Use cp_build_fold_indirect_ref instead
of directly building INDIRECT_REF.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr104981-preview-this.C: New test.
* g++.dg/coroutines/pr115550-preview-this.C: New test.

Reviewed-by: Iain Sandoe 
Reviewed-by: Jason Merrill 
(cherry picked from commit 7c5a9bf1d206fe20cb050200d4a30f11c76b1b19)

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

--- Comment #7 from GCC Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:7c5a9bf1d206fe20cb050200d4a30f11c76b1b19

commit r15-2210-g7c5a9bf1d206fe20cb050200d4a30f11c76b1b19
Author: Patrick Palka 
Date:   Mon Jul 22 21:30:49 2024 -0400

c++/coroutines: correct passing *this to promise type [PR104981]

When passing *this to the promise type ctor (or to its operator new)
(as per [dcl.fct.def.coroutine]/4), we add an explicit cast to lvalue
reference.  But this is unnecessary since *this is already always an
lvalue.  And doing so means we need to call convert_from_reference
afterward to lower the reference expression to an implicit dereference,
which we're currently neglecting to do and which causes overload
resolution to get confused when computing argument conversions.

So this patch removes this unneeded reference cast when passing *this
to the promise ctor, and removes both the cast and implicit deref when
passing *this to operator new, for consistency.  While we're here, use
cp_build_fold_indirect_ref instead of directly building INDIRECT_REF.

PR c++/104981
PR c++/115550

gcc/cp/ChangeLog:

* coroutines.cc (morph_fn_to_coro): Remove unneeded calls
to convert_to_reference and convert_from_reference when
passing *this.  Use cp_build_fold_indirect_ref instead
of directly building INDIRECT_REF.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr104981-preview-this.C: New test.
* g++.dg/coroutines/pr115550-preview-this.C: New test.

Reviewed-by: Iain Sandoe 
Reviewed-by: Jason Merrill 

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-22 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Patrick Palka  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #6 from Patrick Palka  ---
Since I already had a small patch nearly done, I finished and posted it at
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657920.html

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-21 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

--- Comment #5 from Iain Sandoe  ---
(In reply to Arsen Arsenović from comment #4)
> the latter seems OK to me - mind proposing a patch?

I am planning on doing some rework on the ramp code-gen in the (very) near
future - so can pick this up on the way (unless Patrick has already done it ...
)

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-21 Thread arsen at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Arsen Arsenović  changed:

   What|Removed |Added

 CC||arsen at gcc dot gnu.org

--- Comment #4 from Arsen Arsenović  ---
the latter seems OK to me - mind proposing a patch?

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-15 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka  ---
The problem seems to be that we're passing the unlowered reference 'this_ref'
to the ctor call, which overload resolution doesn't expect.  Using
convert_from_reference fixes this:

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 97bc211ff67..31d0cb7fd16 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4851,6 +4851,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)
  this_ref = convert_to_reference (rt, this_ref, CONV_STATIC,
   LOOKUP_NORMAL, NULL_TREE,
   tf_warning_or_error);
+ this_ref = convert_from_reference (this_ref);
  vec_safe_push (promise_args, this_ref);
}
  else if (parm.rv_ref)

or equivalently, removing the call to convert_to_reference above which seems to
be unneeded?

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2024-07-15 Thread arsen at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Arsen Arsenović  changed:

   What|Removed |Added

 CC||ldalessandro at gmail dot com

--- Comment #2 from Arsen Arsenović  ---
*** Bug 114142 has been marked as a duplicate of this bug. ***

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2022-04-18 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

--- Comment #1 from Iain Sandoe  ---
the coroutines code appears to be passing reasonable input to the CTOR build
call.

coroutines.cc:4922:
r = build_special_member_call (p, complete_ctor_identifier, NULL,
   promise_type, LOOKUP_NORMAL,
   tf_warning_or_error);


I think I will need some help from folks more knowledgeable about the lookup
code.

[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter

2022-04-18 Thread iains at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981

Iain Sandoe  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2022-04-18