https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101695
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #51268|0 |1 is obsolete| | --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Created attachment 51269 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51269&action=edit Tar file with reproducer Slightly further reduced. The bug is the visibility of this symbol: 0000000000000000 W _ZN8DelegateIFvPvEE4bindI11MemoryArenaXadL_ZNS4_7destroyIN12_GLOBAL__N_16TesterEEEvS0_EEEERS2_PT_ That should have internal linkage. Because both aaa.o and bbb.o contain that as a weak symbol, the linker merges them and only keeps the first one, which runs the destroy<{aaa.cpp anonymous namespace}::Tester> specialization, which casts the void* to that type and so deletes it as the wrong type, which runs the wrong destructor, and decrements the wrong counter.