This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug overriding global delete operator
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Bug overriding global delete operator
- From: Matthew Seidl <seidl at vex dot cs dot colorado dot edu>
- Date: Thu, 10 Feb 2000 10:16:50 -0700
- cc: seidl at vex dot cs dot colorado dot edu
Gcc version:
gcc version 2.95.2 19991024 (release)
Architecture:
SunOS vex 4.1.3_U1 1 sun4m
Compiler flags:
g++ matt.cc
Source:
source included below sig.
Bug:
I believe there is a bug (according to the c++ spec) in
gcc-2.95.2/gcc/cp/new2.cc
For the new operators it correctly calls the system ::operator new,
but for delete it calls free, not ::operator delete. Therefor, with
the below program, only the printf in the new operator is run.
In gcc 2.7.2.1, both operators are correctly overloaded, and both
printf's run. At least on the architecture listed above.
Thank you for taking a look at this.
-=- Matthew L. Seidl email: seidl@cs.colorado.edu =-=
=-= Graduate Student Project . . . What Project? -=-
-=- http://www.cs.colorado.edu/~seidl/Home.html -Morrow Quotes =-=
=-= http://www.cs.colorado.edu/~seidl/lawsuit -=-
#include <stdlib.h>
#include <iostream.h>
#include <assert.h>
#include <stdio.h>
void* operator new(size_t size)
{
printf("In my new\n");
fflush(stdout);
return malloc(size);
}
void operator delete(void* p)
{
printf("In my delete\n");
fflush(stdout);
free(p);
}
void main() {
int *foo;
foo = new int[10];
delete [] foo;
}