This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: ambiguity in operator delete
- To: zvyagin at gams dot ihep dot su
- Subject: Re: ambiguity in operator delete
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 23 Oct 1999 19:29:25 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <Pine.LNX.3.96.991023174222.27798A-100000@gams.ihep.su>
> This is slightly changed code - I removed keyword "virtual". The
> error message remains the same.
> File b2.c:
> class A { public: void operator delete (void *ptr); };
> class N: public A { };
> class C1: public A { public: ~C1(); };
> class C2: public C1, public N { public: ~C2(); };
> C2::~C2(){}
To remove the error message, you must use virtual in both places.
> This your statement will remain true for default operator delete also!
No. The default operator delete is a global function, not a method.
Lookup of functions does not take objects (or sub-objects) into
account.
> One more argument.
Please understand that arguing about C++ is not something useful for
gcc-bugs@gcc.gnu.org. As a developer of a C++ compiler, my primary
concern is not what users think how C++ should work, but what the
standard says how C++ works.
So pointing me to the right place in the standard would have more
easily convinced me: 12.5/6 says
# Any deallocation function for a class X is a static member (even if
# not explicitly declared static).
Since the delete operator is a static function, 10.2/5 applies, which
says that your code is correct, and that g++ is wrong in complaining
about an ambiguity.
Regards,
Martin