This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
"delete this;" in const member function?
- To: egcs-bugs at cygnus dot com
- Subject: "delete this;" in const member function?
- From: Ingolf Koch <ingolf at mathematik dot uni-jena dot de>
- Date: Mon, 9 Feb 1998 16:33:49 +0100 (MET)
Hi,
the following might not be standard compliant:
class A {
public:
A* clone() const {return new A(*this);}
void kill() const {delete this;}
};
Is it allowed to "delete this" in a const member function?
egcs compiles this piece of code without any warning (even
when -Wall is given), while for example DEC cxx 5.7 treats
it as an error.
Regards
--
Ingolf Koch http://www.minet.uni-jena.de/~ingolf/
FSU Jena, Institut fuer Angewandte Mathematik, 07740 Jena