Bug 16514 - no warning of non-virtual dtor in subclass
Summary: no warning of non-virtual dtor in subclass
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-13 10:20 UTC by naiman
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description naiman 2004-07-13 10:20:10 UTC
Dear G++ Folk,

An astute student found the following example:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
class foo1 {
public:
    virtual void f1 (void) {}
    virtual ~foo1 (void);
};

class foo2 : public foo1 {
public:
    ~foo2 (void);
};
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We believe the compiler should at least warn that foo2
has a virtual function, and non-virtual dtor.

Thank you for your time!

ATB,

Aaron Naiman

--
Aaron ("Aharon") Naiman | Jerusalem College of Technology--Machon Lev
  naiman@math.jct.ac.il | http://math.jct.ac.il/~naiman
Comment 1 Falk Hueffner 2004-07-13 10:28:40 UTC
foo2 does have a virtual destructor. Whether you write the "virtual" keyword
or not is irrelevant.
Comment 2 Gabriel Dos Reis 2004-07-13 11:53:10 UTC
Subject: Re:  New: no warning of non-virtual dtor in subclass

naiman at math dot jct dot ac dot il:
> Dear G++ Folk,
>
> An astute student found the following example:
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> class foo1 {
> public:
>     virtual void f1 (void) {}
>     virtual ~foo1 (void);
> };
>
> class foo2 : public foo1 {
> public:
>     ~foo2 (void);
> };
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> We believe the compiler should at least warn that foo2
> has a virtual function, and non-virtual dtor.

You're mistaken: foo2 has a virtual destructor.


The PR is invalid.