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

            Bug ID: 120890
           Summary: virtual destructor on base class variable does not
                    call derived class destructor when using [] destructor
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Dirk.DeRycke at kla dot com
  Target Milestone: ---

Created attachment 61764
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61764&action=edit
See description.

The virtual destructor of the derived class is not called when calling delete
[] on an array of base pointers. 

However calling virtual members through the base class does work.
When dropping the array and using a single object there is no problem either.

This doesn't work in GCC 14.2. 14.3 and 15.1 
I checked the misbehaving code on
Cfr compiler explorer https://godbolt.org/
Besides a redhat 14.2.1 compiler and a buildroot crosstool 14.2.x


In attach tar.gz containing
gcc14bug.cpp  -> the faulting programm using object arrays []
bug_gcc_expected_result.txt -> correct results from GCC 11,12,13
bug_gcc_wrong_result.txt   -> wrong results from GCC 14,15
gcc14bug_no_array.cpp -> dropping arrays makes it work

Reply via email to