https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86013
Bug ID: 86013 Summary: std::vector::shrink_to_fit() could sometimes use realloc() Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jan.kratochvil at redhat dot com Target Milestone: --- std::vector::shrink_to_fit() when reducing the size it still calls new()+copy. It could use realloc() when the objects are trivially copyable resulting in no copy during size reduction. Maybe it could even always call realloc() for size reduction of any type of objects and just assert the returned pointer did not change.