https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69774
TC <rs2740 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rs2740 at gmail dot com --- Comment #2 from TC <rs2740 at gmail dot com> --- You have a dangling reference - the lambda in Thread's constructor captures `task` by reference, and in this case `task` is bound to the temporary object created by the lambda expression in A's constructor, which is immediately destroyed at the semicolon.