https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89303

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
          Component|libstdc++                   |c++

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The test behaves correctly if -O1 is combined with any (one or more) of:

-fno-guess-branch-probability
-fno-inline-functions-called-once
-fno-tree-forwprop
-fno-tree-fre
-fno-tree-pta

The bug did appear with the r268114 change to shared_ptr but that seems to have
just exposed a latent compiler bug.

It appears that the enable_shared_from_this<blob> destructor doesn't run after
~blob() runs, and so the _M_weak_count member is not decremented by that
destructor. As a result, once the last shared_ptr drops its reference the weak
count remains above zero and so the control block is never destroyed.

Reply via email to