public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Rebecca Ribas <beky.ribas@gmail.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Confused about coroutine behavior
Date: Fri, 26 Aug 2022 10:12:02 +0100	[thread overview]
Message-ID: <CAH6eHdTFVQVYi34B3t=oQP9U2F0-BD+A97JpepTLuOq04Z8rgQ@mail.gmail.com> (raw)
In-Reply-To: <CALoH1AMm4muBJZGYK05oBt57i_aE2gxAfy5AYbByaBnsXh6WOg@mail.gmail.com>

On Fri, 26 Aug 2022 at 06:56, Rebecca Ribas via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi gcc list,
>
> I'm learning c++ coroutines but I ran into a behavior that I can't make
> sense of.
>
> Here is the godbolt link: https://godbolt.org/z/rdPo8ceKP
>
> In some cases, it appears that temporaries are incorrectly freed, the code
> shows test1 and test2 that works as expected, but test3 raises a "used
> after free" error from address sanitizer that doesn't make sense to me.
>
> I'm aware that there are some potential caveats with passing references to
> a coroutine, so I'm possibly missing some subtle detail. But it looks like
> it might be a gcc bug since the same doesn't happen with clang.

Yes, it's probably a bug. There have been a few bugs with temporaries
and coroutines, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98401

If yours is different to that one, please file a new bug in bugzilla.
If you need an account, please email the address given when trying to
sign up for an account and we'll create one promptly.

Thanks!


>
> I tested a few different versions of g++ available on ubuntu and godbolt
> but got the same result.
>
> The compilations flags I used were: -ggdb3 -Og -std=c++20 -Wall -Wextra
> -Werror -D_GLIBCXX_DEBUG -fsanitize=address
>
> Cheers!

      parent reply	other threads:[~2022-08-26  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26  5:55 Rebecca Ribas
2022-08-26  5:55 ` Rebecca Ribas
2022-08-26  9:12 ` Jonathan Wakely [this message]

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='CAH6eHdTFVQVYi34B3t=oQP9U2F0-BD+A97JpepTLuOq04Z8rgQ@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=beky.ribas@gmail.com \
    --cc=gcc@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).