https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89303
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #8) > (In reply to Richard Biener from comment #5) > > GIMPLE at -O1 looks OK-ish - release on all paths: > > But release decrements the weak_count, and only calls _M_destroy() if the > count reaches zero. > > The attachment in comment 7 removes all the atomics and still shows the same > problem. Compiling it with -DFIXME adds: else __builtin_puts("null"); in _M_weak_release(), and that fixes it despite that else branch never actually being taken. Just the presence of I/O appears to prevent that function being misoptimized.