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]

Re: missing warning


A (At) 1:20 25/11/98, Alexander V. Lukyanov ecrivait (wrote):
>On Tue, Nov 24, 1998 at 04:52:54PM +0100, Valentin Bonnard wrote:
>> Alexander V. Lukyanov wrote:
>> 
>> > In the following C++ program the ~B destructor is not called (egcs-1.1). I
>> > know why, but none the less I beleave a warning is required.
>> 
>> > #include <stream.h>
>> > class A
>> > {
>> > public:
>> >    virtual void func() = 0;
>> 
>> // error #1: missing virtual dtor
>> 
>> > };
>> > class B : public A
>> 
>> // error #2: inheriting from class w/o virtual dtor
>> 
>> > {
>> > public:
>> >    void func() {};
>> >    virtual ~B() { cout << "~B\n"; }
>> > };
>> > int main()
>> > {
>> >    A *a=new B();
>> // error #3: up-casting a class w/o virtual dtor
>> >    delete a;
>> // error #4: deleting    "     "     "
>> >    return 0;
>> > }
>
>Ok, summary: the code has defined behaviour,

Again, _no_, it doesn't

>and each mentioned potential
>point of error has legal cases of usage.

Yes. And it well-formed so should not be diagnosed.

>So a warning could be wrong
>in any of the cases, thus better to have no warning.

Sorry I don't follow this resonning.

[ Please cc replies to me ]


Valentin Bonnard                mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/




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