public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jehelset at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/97587] New: [coroutines] promise_type constructor is called with original parameters, not parameter copies
Date: Tue, 27 Oct 2020 05:35:17 +0000	[thread overview]
Message-ID: <bug-97587-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2020-10-27  5:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27  5:35 jehelset at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97587-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).