Hi,

recently I wrote the tiny program attached below to test overloading of new and
delete. Unfortunately, the overloaded delete[] operator does not get called.
:-(

System: Linux HOSTNAME 2.6.17-1.2187_FC5 #1 SMP Mon Sep 11 01:16:59 EDT 2006
x86_64 x86_64 x86_64 GNU/Linux
g++: g++ (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
 g++32 (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-55.fc5)

=================================================================

#include <iostream>
using namespace std;

class myclass {
    public:
        static void * operator new (std::size_t size) throw() {
            cout << "myclass new operator\n";
            return NULL;
        }
        static void * operator new[] (std::size_t size) throw() {
            cout << "myclass new[] operator\n";
            return NULL;
        }
        static void operator delete (void *p) throw() {
            cout << "myclass delete operator\n";
        }
        static void operator delete[] (void *p) throw() {
            cout << "myclass delete[] operator\n";
        }
};

int main() {
    myclass *ad;

    ad = new myclass;
    ad = new myclass[10];
    delete[] ad;
    delete ad;

    return 0;
}

=================================================================


-- 
           Summary: Overloaded operator delete[] doesn't get called
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Andreas dot Kowarz at tu-dresden dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29163

Reply via email to