This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16441] Problen in overloading delete operator.
- From: "uttamkumar at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2004 12:38:31 -0000
- Subject: [Bug c++/16441] Problen in overloading delete operator.
- References: <20040708190056.16441.uttamkumar@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From uttamkumar at hotmail dot com 2004-07-09 12:38 -------
(In reply to comment #0)
> I have compilation problem in overloading operator delete.
/********************************************
File : test.cpp
How to compile:
g++ -g -D_REENTRANT -Wall -ansi -ggdb3 -c test.cpp
********************************************/
#include<stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std ;
inline void operator delete (void *reportedAddress , const char *file,int
line,const char *func)
{
cout<< "Delete:"<<" File:"<<file<< " Line:"<<line<<" Func:"<<endl;
free ( reportedAddress ) ;
return ;
}
void* operator new (size_t size, const char *file,int line,const char *func)
{
cout<< "New:"<<size<<" File:"<<file<< " Line:"<<line<<"
Func:"<<func<<endl;
return malloc ( size ) ;
}
#ifdef new
#undef new
#endif
#ifdef delete
#undef delete
#endif
#define new new ( __FILE__, __LINE__, __FUNCTION__)
#define delete delete ( __FILE__, __LINE__, __FUNCTION__)
typedef struct {
int x;
int y ;
char s[100] ;
}MyStruct ;
void DummyFunction () {
MyStruct *m = new MyStruct () ;
delete m ;
return ;
}
int main (){
DummyFunction () ;
return 0 ;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16441