Re: delete
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 06/01/04
- Next message: Doug Harrison [MVP]: "Re: how to compare two string?"
- Previous message: Doug Harrison [MVP]: "Re: C run-time library"
- In reply to: Jerry Coffin: "Re: delete"
- Next in thread: Roy Fine: "Re: delete"
- Reply: Roy Fine: "Re: delete"
- Reply: Jerry Coffin: "Re: delete"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 01 Jun 2004 11:25:40 -0500
Jerry Coffin wrote:
>In article <es8kb0t3g5f1pmdp8cj9gfic5l9af1tt8q@4ax.com>, dsh@mvps.org
>says...
>
>[ creating a global "operator delete(void *&);" ]
>
>> It's illegal. The first parameter of operator delete must be void*.
>
>True -- that was why I said you "_might_" be able to do it, rather
>than that you could. Some older compilers accepted it (sorry, I
>don't remember which ones and I'm far too lazy to re-install every
>old compiler I have to figure out) but it's barely possible that the
>OP is using one that'll accept it even though the standard doesn't
>allow it.
>
>Even now, precise conformance with the C++ standard remains the
>exception rather than the rule...
Even VC6 (circa 1998) rejects that approach. In addition, you clipped the
part where I went on to explain that even if you used an old compiler that
allowed the overloading of operator delete on void*&, you'd still run into
ambiguities when you tried to use it:
*****
In addition, the following is ambiguous:
void f(void*);
void f(void*&);
void* p = 0;
f(p); // Ambiguous
However, this is fine, due to the strange interaction between overload
resolution and rvalues:
f((void*) p); // Selects f(void*)
*****
So there are multiple reasons why it doesn't work, and even if it did work
under some ancient compiler, imagine the effects of moving to a newer one.
Not only is your code immediately broken, you labored all that time with the
wrong understanding of the delete operator, or at best, you came to rely on
a crutch, which in the world of VC++, hasn't had a leg to stand on in at
least six years. Earlier, you did characterize it as a "poor idea", and I
elaborated on why it's an exceedingly poor idea, but in your reply, you seem
to have backed away from that. Bottom line: Even if it could be used, it
should not be used.
-- Doug Harrison Microsoft MVP - Visual C++
- Next message: Doug Harrison [MVP]: "Re: how to compare two string?"
- Previous message: Doug Harrison [MVP]: "Re: C run-time library"
- In reply to: Jerry Coffin: "Re: delete"
- Next in thread: Roy Fine: "Re: delete"
- Reply: Roy Fine: "Re: delete"
- Reply: Jerry Coffin: "Re: delete"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|