https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120987
--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #15) > (In reply to Tom de Vries from comment #14) > > I've managed to write a synthetic example: > > I've bisect this to: > ... > commit 4d6132e59327e809a4d4e39fb9465dbd43775b7c > Author: Richard Biener <rguent...@suse.de> > Date: Thu Aug 10 13:55:36 2023 +0200 > > tree-optimization/110963 - more PRE when optimizing for size > ... It also happens (testing with GCC 15) with -fdisable-tree-pre, -fno-tree-pre -fno-code-hoisting with both -O1 and -O2. So this must be sth else? Valgrind on the -O1 executable says ==20710== Invalid read of size 8 ==20710== at 0x400E88: main (t.C:79) ==20710== Address 0x4e16170 is 16 bytes inside a block of size 48 free'd ==20710== at 0x48458F9: operator delete(void*, unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==20710== by 0x400F41: deallocate (new_allocator.h:172) ==20710== by 0x400F41: deallocate (alloc_traits.h:649) ==20710== by 0x400F41: ~__allocated_ptr (allocated_ptr.h:74) ==20710== by 0x400F41: std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_destroy() (shared_ptr_base.h:625) ==20710== by 0x400FD2: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:346) ==20710== by 0x400E00: ~__shared_count (shared_ptr_base.h:1069) ==20710== by 0x400E00: ~__shared_ptr (shared_ptr_base.h:1531) ==20710== by 0x400E00: ~shared_ptr (shared_ptr.h:175) ==20710== by 0x400E00: ~gdb_exception (t.C:5) ==20710== by 0x400E00: parse_linespec() (t.C:68) so it seems to be some kind of lifetime issue?