Bug overriding global delete operator
Matthew Seidl
seidl@vex.cs.colorado.edu
Thu Feb 10 09:22:00 GMT 2000
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;
}
More information about the Gcc-bugs
mailing list