https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86013
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- You're jumping through arcane hoops just to provide a property which is not guaranteed by the function and was never intended to be supported. If you don't want shrink_to_fit to reallocate then stop calling it.