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

            Bug ID: 96614
           Summary: constexpr deletion failure through pointer to base
                    with virtual base class
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pkeir at outlook dot com
  Target Milestone: ---

Created attachment 49062
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49062&action=edit
A C++ file containing the code described.

The C++20 code below (also attached) fails to compile with GCC trunk.

struct FooBase {
  constexpr virtual ~FooBase() {}
};

struct Foo : public FooBase {};

constexpr bool test()
{
  FooBase* pb = new Foo;
  delete pb;

  return true;
}

int main(int argc, char *argv[])
{
  static_assert(test());
  test(); // no problem

  return 0;
}

The error is invoked by the `static_assert` expression, and relates to the call
to `delete pb`. It states:

virtual constexpr Foo::~Foo()’ used before its definition

Reply via email to