https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121177

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
   Last reconfirmed|                            |2025-07-19
          Component|c++                         |tree-optimization
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
  _24 = (long unsigned int) n_2(D);
  _25 = operator new [] (_24);
  g (_25, n_2(D));
...
  _34 = operator new (_24);
  __builtin_memcpy (_34, _25, _24);
  operator delete [] (_25);
  _44 = operator new (_24);
  _4(D)->D.85381._M_impl.D.84649._M_start = _44;
  _31 = _44 + _24;
  _4(D)->D.85381._M_impl.D.84649._M_end_of_storage = _31;
  __builtin_memcpy (_44, _34, _24);
  _4(D)->D.85381._M_impl.D.84649._M_finish = _31;
  operator delete (_34, _24);
```

At least one copy (_34) could be removed I think.
GCC does remove the "copies" when the size is 0 but that is via jump threading.

Reply via email to