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

            Bug ID: 119162
           Summary: missing error with constexpr new
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2025-March/676945.html>:

```
constexpr int *
f7 ()
{
  int *p = new int (2);
  delete p;
  return p;
}

void
g ()
{
  constexpr auto v7 = f7 ();
}
```
should give an error but doesn't.  clang++ says:

q.C:12:18: error: constexpr variable 'v7' must be initialized by a constant
expression
   12 |   constexpr auto v7 = f7 ();
      |                  ^    ~~~~~
q.C:12:18: note: pointer to heap-allocated object is not a constant expression

Reply via email to