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

            Bug ID: 119304
           Summary: invalid placement new inside constexpr accetped for
                    C++26
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, c++26
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 55004
  Target Milestone: ---

Consider:
```
constexpr void *operator new (__SIZE_TYPE__, void *p) noexcept { return p; }

constexpr int f ()
{
  const int i = 0;
  int *p = new ((int*)&i) int (1);
  return *p;
}

constexpr int i = f ();
```

This should be rejected as we can change the value of i which is const and that
would be invalid.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues

Reply via email to