inline operator delete redefinition and in-charge deleting destructor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have the following problem with gcc3.3.3 on Solaris:

If providing the definition of a destructor outside the module where
"delete" is called, the compiler instantiates a function call to delete
to the standard library, thus missing my definition.

See the following program:

Of course, I comment out the "#include "new"" in ddef.cxx the program
works.

Similarly if I don't inline the operator delete I get a correct
behavior.

Do I miss something ? is it a problem with the "inline" keyword that
don't provide a definition preempting the one from the library ?
Shouldn't inlined functions provide their body in case they are not
member functions ?

Does the "language" forces me to include "new" for every implicit call
to memory operators ?

Thank you,

--- i.h ---
class MyClass
{
public:
  virtual ~MyClass(void);
};


--- new ---
extern int glob;

inline void operator delete(void *p)
{
  glob++;
}

--- ddef.cxx ---
#include "i.h"

MyClass::~MyClass(void)
{
}

--- foo.cxx ---
#include <stdio.h>
#include "i.h"

// explicit call to delete. include definition
#include "new"

int glob;

main()
{
  MyClass *b = new MyClass;	
  delete b;

  if (glob != 1)
    printf ("FAILED %d\n", glob);
  else
    printf ("SUCCESS\n");
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux