https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62006
--- Comment #11 from Thomas Köppe <tkoeppe at google dot com> --- Created attachment 33240 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33240&action=edit Further fixing: Uses uintptr_ts for the difference On Jonathan's suggestion I changed the distance computation to go through a uintptr_t conversion. Jonathan suggested compiling with -fno-elide-constructors, and indeed the attached code breaks when that option is passed. As you said, the UB caused by the distance computations of automatic objects seems to be the stumbling point.