[Bug c++/118577] Deleted dtor trying to override non-deleted one with user-defined 'operator delete' is not forbidden

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 21 07:57:51 GMT 2025


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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Adding:
```

void f()
{
        C a;
}
```

GCC now rejects it with a similar message as clang:
```
<source>: In destructor 'virtual C::~C()':
<source>:8:8: error: 'static void A::operator delete(void*, int)' is private
within this context
    8 | struct C : /*mut1*/private B {};
      |        ^
<source>:5:8: note: declared private here
    5 | struct B : /*mut1*/private A {
      |        ^
<source>:8:8: error: no suitable 'operator delete' for 'C'
    8 | struct C : /*mut1*/private B {};
      |        ^
<source>: In function 'void f()':
<source>:13:11: note: synthesized method 'virtual C::~C()' first required here
   13 |         C a;
      |           ^
```

I am not 100% sure if the synthesized method deconstructor should happen always
or not.


More information about the Gcc-bugs mailing list