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!

Reply via email to