https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89303
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45682|0 |1 is obsolete| | --- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> --- Created attachment 45684 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45684&action=edit Testcase for both bugs This new attachment can be used to reproduce both bugs, for any GCC version from 5.1.0 onwards, with -O1. By default it shows the memory leak, but when BAD_WEAK_PTR_BUG is defined it demonstrates the unexpected exception. Defining FIXME makes both bugs go away. I've confirmed that the original bug is caused by _M_weak_this._M_refcount._M_pi being null: (gdb) p tg $1 = {_M_ptr = 0x614e80, _M_refcount = {_M_pi = 0x614e70}} (gdb) p *tg._M_ptr $2 = {<std::__enable_shared_from_this<blob, 0>> = {_M_weak_this = {_M_ptr = 0x614e80, _M_refcount = {_M_pi = 0x0}}}, data = 0x614ea0} Bisecting from 4.9 to 5.1 shows the bug started with r221859: 2015-04-03 Jan Hubicka PR ipa/65076 * ipa-inline.c (edge_badness): Add combined size to the denominator.