Possible Duplicate:
Deleting a pointer to const (T const*)
void operator delete (void*);
...
const char *pn = new char, *pm = (char*)malloc(1);
delete pn; // allowed !!
free(pm); // error
Demo.
It’s understandable that free() is a function, so a const void* cannot be converted to void*. But why is it allowed in the case of operator delete (default or overloaded) ?
Is it not functionally a wrong construct ?
While I quite agree with @JamesKanze’s answer, perhaps somebody would like to see what the standard actually says. According to the standard (§12.1/4):
and (§12.4/2):
In fairness, this does little more than re-state what @James said, a bit more specifically: the object is only really considered an object from the time the ctor finishes (or all the ctors, when inheritance is involved) to the point that the first dtor begins. Outside those boundaries, const and volatile aren’t enforced.