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

            Bug ID: 128201
           Summary: aligned operator new alignment can be found via
                    argument
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take C++17 code:
```
struct alignas(1024) s1
{
  int t[1024];
};
void f()
{
  s1 *a = new s1();
  a = (s1*)__builtin_assume_aligned(a, 1024);
  delete a;
}
```

The assume_aligned here can be folded away since we know the alignment is 1024
via the operator new call:
```
_3 = operator new (4096, 1024); // _ZnwmSt11align_val_t
```

Reply via email to