[Bug c++/29164] New: Overloaded operator delete[] doesn't get called
Andreas dot Kowarz at tu-dresden dot de
gcc-bugzilla@gcc.gnu.org
Thu Sep 21 10:44:00 GMT 2006
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)
Regards,
Andreas Kowarz
=================================================================
#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;
}
=================================================================
Output:
myclass new operator
myclass new[] operator
myclass delete operator
--
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=29164
More information about the Gcc-bugs
mailing list