public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Iain Sandoe <iain@sandoe.co.uk>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH RFC] c++: fix broken conversion in coroutines
Date: Mon, 3 Oct 2022 23:53:06 -0400	[thread overview]
Message-ID: <d2f23c31-90b3-b73c-0bec-d8f2c94e5bb9@redhat.com> (raw)
In-Reply-To: <219253A3-8202-4286-9621-982BC5CD24DF@sandoe.co.uk>

On 9/30/22 18:50, Iain Sandoe wrote:
> Hi Jason,
> 
>> On 30 Sep 2022, at 23:06, Jason Merrill <jason@redhat.com> wrote:
>>
>> You can't use CONVERT_EXPR to convert between two class types, and it was
>> breaking copy elision.
>>
>> Unfortunately, this patch breaks symmetric-transfer-00-basic.C, where
>> susp_type is Loopy<int>::handle_type.  How is this supposed to work?
> 
> We are trying to save a type-erased handle (which the symmetric transfer makes
> and indirect call through, nothing else).

The problem is you're treating one class directly as another class here, 
without the indirection involved in usual type-erasure idioms.

It does seem that the gimplifier handles this fine, but it doesn't 
correspond to anything in the language and much of the front end assumes 
that CONVERT_EXPR is only used for scalars.  VIEW_CONVERT_EXPR would 
better express that we're not doing anything to the value, just cheating 
the type system.  That's still dodgy from a language perspective, but 
probably safe enough in this case.

Note that I was wrong to mention copy elision above; it's irrelevant to 
codegen here since the handle type returns in a register.

> so, I suppose the equivalent could be:
> 
> conthand = coroutine_handle::from_address (suspend.address())

That sounds more correct, yes.

Jason


  reply	other threads:[~2022-10-04  3:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 22:06 Jason Merrill
2022-09-30 22:50 ` Iain Sandoe
2022-10-04  3:53   ` Jason Merrill [this message]
2022-10-06 21:44     ` Jason Merrill
2022-10-06 22:47       ` Iain Sandoe

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=d2f23c31-90b3-b73c-0bec-d8f2c94e5bb9@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    /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).