[Bug c++/95491] New: coroutines: awaited temporaries are never destructed
max at duempel dot org
gcc-bugzilla@gcc.gnu.org
Wed Jun 3 06:52:27 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95491
Bug ID: 95491
Summary: coroutines: awaited temporaries are never destructed
Product: gcc
Version: 10.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: max at duempel dot org
Target Milestone: ---
Created attachment 48665
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48665&action=edit
Small program demonstrating the bug
If a coroutine uses `co_await` on a temporary (i.e. the temporary lives only in
a scope that contains the suspend point), the temporary never gets destructed.
My demo with "gcc version 10.1.0 (Debian 10.1.0-3)" (Debian Bullseye/Sid):
$ g++ -fcoroutines coroutine_leak.cxx && ./a.out
construct Bar
Bar() = 42
This is with "clang version 10.0.0-4":
$ clang++ -fcoroutines-ts -stdlib=libc++ coroutine_leak.cxx && ./a.out
construct Bar
Bar() = 42
destruct Bar
clang calls the destructor, and gcc doesn't. With -fsanitize=address (and a
different program which allocates a "real" coroutine instead of a class with an
"operator co_await"), I can see memory leaks being detected.
More information about the Gcc-bugs
mailing list