public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies
@ 2020-10-27 5:35 jehelset at gmail dot com
2021-02-16 8:47 ` [Bug c++/97587] " iains at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jehelset at gmail dot com @ 2020-10-27 5:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97587
Bug ID: 97587
Summary: [coroutines] promise_type constructor is called with
original parameters, not parameter copies
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jehelset at gmail dot com
Target Milestone: ---
Created attachment 49443
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49443&action=edit
Program that results in assertion-failure due to wrong arguments to promise.
The promise-type constructor should be called with the parameter copies from
the coroutine-frame. I couldn't quite understand that this is supposed to be
the case from the current draft of the standard, but I got some help from Lewis
Baker who also referred me to this rewording, where in the previous version it
is clear:
https://github.com/cplusplus/draft/commit/0b4ab68a54e197eba9d894a8f91270bb0dcdb546
The attached code triggers an assertion that show that this is not the case on
gcc. I initially had the problem on gcc-10.2.0, but reproduced it on gcc-trunk
on godbolt. Compile either version with -fcoroutines, or see
https://gcc.godbolt.org/z/j16Wqx.
I speculated that the logic here,
https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/coroutines.cc#L4491-L4494,
was inverted. It seemed to pass the copied version of a by-reference parameter,
but the original version of a by-value parameter. The opposite would not
trigger the assertion. But I am not that familiar.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/97587] [coroutines] promise_type constructor is called with original parameters, not parameter copies
2020-10-27 5:35 [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies jehelset at gmail dot com
@ 2021-02-16 8:47 ` iains at gcc dot gnu.org
2021-02-25 19:34 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: iains at gcc dot gnu.org @ 2021-02-16 8:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97587
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-02-16
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |iains at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
Created attachment 50194
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50194&action=edit
Patch under test
this needs a changelog, and some wider testing.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/97587] [coroutines] promise_type constructor is called with original parameters, not parameter copies
2020-10-27 5:35 [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies jehelset at gmail dot com
2021-02-16 8:47 ` [Bug c++/97587] " iains at gcc dot gnu.org
@ 2021-02-25 19:34 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:03 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:45 ` iains at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-25 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97587
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:
https://gcc.gnu.org/g:b8ff3f8efeda02a6bedebfaf20b93645ae3bb5b8
commit r11-7403-gb8ff3f8efeda02a6bedebfaf20b93645ae3bb5b8
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Mon Feb 15 16:13:36 2021 +0000
coroutines : Call promise CTOR with parm copies [PR97587].
As the PR notes, we were calling the promise CTOR with the original
function parameters, not the copy (as pointed, a previous wording of
the section was unambiguous). Fixed thus.
gcc/cp/ChangeLog:
PR c++/97587
* coroutines.cc (struct param_info): Track rvalue refs.
(morph_fn_to_coro): Track rvalue refs, and call the promise
CTOR with the frame copy of passed parms.
gcc/testsuite/ChangeLog:
PR c++/97587
* g++.dg/coroutines/coro1-refs-and-ctors.h: Add a CTOR with two
reference parms, to distinguish the rvalue ref. variant.
* g++.dg/coroutines/pr97587.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/97587] [coroutines] promise_type constructor is called with original parameters, not parameter copies
2020-10-27 5:35 [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies jehelset at gmail dot com
2021-02-16 8:47 ` [Bug c++/97587] " iains at gcc dot gnu.org
2021-02-25 19:34 ` cvs-commit at gcc dot gnu.org
@ 2021-03-22 22:03 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:45 ` iains at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-22 22:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97587
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:
https://gcc.gnu.org/g:88bb77a8dcf75f556b8dcb24b8785b4567d24e4f
commit r10-9511-g88bb77a8dcf75f556b8dcb24b8785b4567d24e4f
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Mon Feb 15 16:13:36 2021 +0000
coroutines : Call promise CTOR with parm copies [PR97587].
As the PR notes, we were calling the promise CTOR with the original
function parameters, not the copy (as pointed, a previous wording of
the section was unambiguous). Fixed thus.
gcc/cp/ChangeLog:
PR c++/97587
* coroutines.cc (struct param_info): Track rvalue refs.
(morph_fn_to_coro): Track rvalue refs, and call the promise
CTOR with the frame copy of passed parms.
gcc/testsuite/ChangeLog:
PR c++/97587
* g++.dg/coroutines/coro1-refs-and-ctors.h: Add a CTOR with two
reference parms, to distinguish the rvalue ref. variant.
* g++.dg/coroutines/pr97587.C: New test.
(cherry picked from commit b8ff3f8efeda02a6bedebfaf20b93645ae3bb5b8)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/97587] [coroutines] promise_type constructor is called with original parameters, not parameter copies
2020-10-27 5:35 [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies jehelset at gmail dot com
` (2 preceding siblings ...)
2021-03-22 22:03 ` cvs-commit at gcc dot gnu.org
@ 2021-03-24 12:45 ` iains at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: iains at gcc dot gnu.org @ 2021-03-24 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97587
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
fixed for master and 10.3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-24 12:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 5:35 [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies jehelset at gmail dot com
2021-02-16 8:47 ` [Bug c++/97587] " iains at gcc dot gnu.org
2021-02-25 19:34 ` cvs-commit at gcc dot gnu.org
2021-03-22 22:03 ` cvs-commit at gcc dot gnu.org
2021-03-24 12:45 ` iains at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).