public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Confused about coroutine behavior
@ 2022-08-26  5:55 Rebecca Ribas
  2022-08-26  5:55 ` Rebecca Ribas
  2022-08-26  9:12 ` Jonathan Wakely
  0 siblings, 2 replies; 3+ messages in thread
From: Rebecca Ribas @ 2022-08-26  5:55 UTC (permalink / raw)
  To: gcc

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!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-26  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26  5:55 Confused about coroutine behavior Rebecca Ribas
2022-08-26  5:55 ` Rebecca Ribas
2022-08-26  9:12 ` Jonathan Wakely

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).