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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|constexpr alloc             |undefined increment of
                   |                            |deallocated pointer allowed
                   |                            |in constexpr
   Last reconfirmed|                            |2025-03-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |accepts-invalid

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This should be rejected, but all of gcc, clang, msvc and EDG are totally cool
with it:

constexpr bool
test2()
{
  int* p = new int[2];
  int* x = p;
  delete[] p;
  p = new int[4];
  void* v = nullptr;
  for (int i = 0; i < 2; ++i)
    v = x++;
  delete[] p;
  return v != p;
}

static_assert( test2() );


The other compilers give an error if x is increment more than twice, but GCC
let's you keep incrementing it.

Reply via email to