This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

"delete this;" in const member function?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]