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

            Bug ID: 105826
           Summary: failure to compile namespace-scope constexpr
                    new-expression
           Product: gcc
           Version: 12.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/2022-June/596134.html>, this should
compile in C++20:

struct A
{
  int i;
  constexpr A(int *p): i(*p) { delete p; }
};

constexpr int i = A(new int(42)).i;

but currently we issue

$ ./cc1plus -quiet q.C -std=c++20
q.C:7:34: error: the value of ‘<anonymous>’ is not usable in a constant
expression
    7 | constexpr int i = A(new int(42)).i;
      |                                  ^
q.C:7:31: note: ‘<anonymous>’ was not declared ‘constexpr’
    7 | constexpr int i = A(new int(42)).i;
      |                               ^

Reply via email to