https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110819
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=110137 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- I guess gcc can't optimize this away because it doesn't know if operator new has side effects. When compiled with clang, libstdc++'s std::vector uses __builtin_operator_new which always has the -fassume-sane-operator-new semantics, and so can be optimized.