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

            Bug ID: 118237
           Summary: failure to compile constexpr variable initialization
                    with properly destroyed allocation inside the
                    expression
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hanicka at hanicka dot net
  Target Milestone: ---

Hi,

I was looking into dynamic allocation tracking, and found simple example which
fails to compile:

`constexpr auto f = (delete new int{42}, 32);`

It seems GCC is not tracking dynamic allocations inside RHS of constexpr
variable definition. This should be valid according to [expr.const] as the
allocation is destroyed within evaluation of E (here `(delete new int{42},
32)`)

Other compilers do accept this snipper:

https://compiler-explorer.com/z/zeae1MP9d

The bug is present in all versions of GCC since support dynamic allocations
inside constant evaluation (GCC 10).

Reply via email to