Confused about coroutine behavior
Rebecca Ribas
beky.ribas@gmail.com
Fri Aug 26 05:55:20 GMT 2022
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.
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!
More information about the Gcc
mailing list