[Bug c++/104981] [coroutines] Internal compiler error when promise object's constructor takes a base class of the object parameter
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 23 01:31:00 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104981
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:7c5a9bf1d206fe20cb050200d4a30f11c76b1b19
commit r15-2210-g7c5a9bf1d206fe20cb050200d4a30f11c76b1b19
Author: Patrick Palka <ppalka@redhat.com>
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 <iain@sandoe.co.uk>
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list