public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <20020713190601.7302.cesarb@nitnet.com.br>
@ 2004-04-30  0:36 ` pinskia at gcc dot gnu dot org
  2004-05-12 15:43 ` bangerth at dealii dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-30  0:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-30 00:31 -------
Closing as a dup of bug 15214 because that one has a start on the patch but it also describes another 
situation.

*** This bug has been marked as a duplicate of 15214 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <20020713190601.7302.cesarb@nitnet.com.br>
  2004-04-30  0:36 ` [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor pinskia at gcc dot gnu dot org
@ 2004-05-12 15:43 ` bangerth at dealii dot org
  2004-05-13 11:26 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: bangerth at dealii dot org @ 2004-05-12 15:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-05-11 18:56 -------
This is indeed not a duplicate of PR 15214 though the two reports certainly 
go into the same direction. Let's keep it open then. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <20020713190601.7302.cesarb@nitnet.com.br>
  2004-04-30  0:36 ` [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor pinskia at gcc dot gnu dot org
  2004-05-12 15:43 ` bangerth at dealii dot org
@ 2004-05-13 11:26 ` jason at gcc dot gnu dot org
  2004-12-09  2:02 ` pinskia at gcc dot gnu dot org
  2005-03-20 17:47 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 29+ messages in thread
From: jason at gcc dot gnu dot org @ 2004-05-13 11:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jason at gcc dot gnu dot org  2004-05-12 19:33 -------
A pure virtual member function can still be defined (and must be, if it is the
destructor).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <20020713190601.7302.cesarb@nitnet.com.br>
                   ` (2 preceding siblings ...)
  2004-05-13 11:26 ` jason at gcc dot gnu dot org
@ 2004-12-09  2:02 ` pinskia at gcc dot gnu dot org
  2005-03-20 17:47 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-09  2:02 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <20020713190601.7302.cesarb@nitnet.com.br>
                   ` (3 preceding siblings ...)
  2004-12-09  2:02 ` pinskia at gcc dot gnu dot org
@ 2005-03-20 17:47 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-20 17:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-20 17:47 -------
*** Bug 20570 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at cohi dot at


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-06-02 21:47 ` manu at gcc dot gnu.org
@ 2011-06-04 16:25 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2011-06-04 16:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #29 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-04 16:24:50 UTC ---
For G++ 4.7 I've added -Wdelete-non-virtual-dtor, included in -Wall, to handle
the case in comment 25, so closing this as fixed now


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-4@http.gcc.gnu.org/bugzilla/>
  2011-06-02 21:30 ` redi at gcc dot gnu.org
  2011-06-02 21:45 ` manu at gcc dot gnu.org
@ 2011-06-02 21:47 ` manu at gcc dot gnu.org
  2011-06-04 16:25 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu.org @ 2011-06-02 21:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302

--- Comment #28 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-06-02 21:46:13 UTC ---
(In reply to comment #26)

> I've posted a patch to http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00191.html
> which gives this for the code in comment 25

BTW, I would suggest that you use warning_at, but I guess this is a lost
battle.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-4@http.gcc.gnu.org/bugzilla/>
  2011-06-02 21:30 ` redi at gcc dot gnu.org
@ 2011-06-02 21:45 ` manu at gcc dot gnu.org
  2011-06-02 21:47 ` manu at gcc dot gnu.org
  2011-06-04 16:25 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu.org @ 2011-06-02 21:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|mueller at gcc dot gnu.org  |redi at gcc dot gnu.org

--- Comment #27 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-06-02 21:43:21 UTC ---
Assigned to you Jonathan!

Feel free to close it when your patch goes in. If there is something else left
to do, it is always better to open a new PR.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-4@http.gcc.gnu.org/bugzilla/>
@ 2011-06-02 21:30 ` redi at gcc dot gnu.org
  2011-06-02 21:45 ` manu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2011-06-02 21:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302

--- Comment #26 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-02 21:29:53 UTC ---
(can this bug be un-ASSIGNED?)

(In reply to comment #25)
> Here, H must have a virtual destructor. The point where it can know it should
> warn is the "delete this;" line.

I've posted a patch to http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00191.html
which gives this for the code in comment 25

7302.cc:16:12: warning: deleting object of abstract class type ‘H’ which has
non-virtual destructor will cause undefined behaviour
[-Wdelete-non-virtual-dtor]


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (18 preceding siblings ...)
  2007-08-20 15:09 ` jason at gcc dot gnu dot org
@ 2007-08-21 10:54 ` cesarb at cesarb dot net
  19 siblings, 0 replies; 29+ messages in thread
From: cesarb at cesarb dot net @ 2007-08-21 10:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #25 from cesarb at cesarb dot net  2007-08-21 10:54 -------
The testcase seems to be missing one case where it should warn:

class H
{
protected:
        ~H();
public:
        virtual void deleteme() = 0;
};

H::~H()
{
}

void
H::deleteme()
{
        delete this;
}

class I : public H
{
protected:
        ~I();
public:
        virtual void deleteme() { H::deleteme(); }
        void oops();
};

I::~I()
{
}

void
I::oops()
{
        deleteme();
}

Here, H must have a virtual destructor. The point where it can know it should
warn is the "delete this;" line.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (17 preceding siblings ...)
  2007-03-20 19:42 ` patchapp at dberlin dot org
@ 2007-08-20 15:09 ` jason at gcc dot gnu dot org
  2007-08-21 10:54 ` cesarb at cesarb dot net
  19 siblings, 0 replies; 29+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-08-20 15:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #24 from jason at gcc dot gnu dot org  2007-08-20 15:08 -------
Subject: Bug 7302

Author: jason
Date: Mon Aug 20 15:08:24 2007
New Revision: 127649

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127649
Log:
        PR c++/7302
        * cp/class.c (finish_struct_1): Warn when a class has virtual
        functions and accessible non-virtual destructor.

        * doc/invoke.texi (-Wnon-virtual-dtor): Update documentation.

        * g++.dg/warn/Wnvdtor-2.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wnvdtor-2.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (16 preceding siblings ...)
  2007-03-20 19:02 ` manu at gcc dot gnu dot org
@ 2007-03-20 19:42 ` patchapp at dberlin dot org
  2007-08-20 15:09 ` jason at gcc dot gnu dot org
  2007-08-21 10:54 ` cesarb at cesarb dot net
  19 siblings, 0 replies; 29+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-20 19:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #23 from patchapp at dberlin dot org  2007-03-20 19:42 -------
Subject: Bug number PR7302

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01347.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (15 preceding siblings ...)
  2007-03-20 18:52 ` pluto at agmk dot net
@ 2007-03-20 19:02 ` manu at gcc dot gnu dot org
  2007-03-20 19:42 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-20 19:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from manu at gcc dot gnu dot org  2007-03-20 19:01 -------
(In reply to comment #21)
> http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01343.html
> 

Hint, if you use the patch queue[1], it takes care of adding a comment pointing
to the patch. Also, your patch lacks a Changelog [2]. See also an example [3].

[1] http://www.dberlin.org/patchdirections.html
[2] http://gcc.gnu.org/codingconventions.html
[3] http://gcc.gnu.org/ml/gcc-patches/2006-12/msg00008.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (14 preceding siblings ...)
  2007-03-16 16:14 ` manu at gcc dot gnu dot org
@ 2007-03-20 18:52 ` pluto at agmk dot net
  2007-03-20 19:02 ` manu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: pluto at agmk dot net @ 2007-03-20 18:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from pluto at agmk dot net  2007-03-20 18:52 -------
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01343.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2007-03-16 15:39 ` pluto at agmk dot net
@ 2007-03-16 16:14 ` manu at gcc dot gnu dot org
  2007-03-20 18:52 ` pluto at agmk dot net
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-16 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from manu at gcc dot gnu dot org  2007-03-16 16:13 -------
(In reply to comment #19)
> (In reply to comment #18)
> 
> > The patch needs testcases,
> 
> i have a testcase but my tcl/autogen/dejagnu crashes
> with magic `spawn failed' message :/
> 

No idea. Ask in the gcc list, perhaps someone could help you. I would just
remove completely and reinstall DejaGNU. Or just use the GCC Compile Farm for
testing. I have a script there that you just say

PATCH=/path/to/patch ./gccfarming bootstrap

And it bootstraps and regression tests the patch and sends you the results by
email. It also has a "patchqueue" mode where filenames of patches are read from
a file and bootstrapped+tested in sequence, and you can add more names at the
end of the file on the fly.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2007-03-16 15:30 ` manu at gcc dot gnu dot org
@ 2007-03-16 15:39 ` pluto at agmk dot net
  2007-03-16 16:14 ` manu at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: pluto at agmk dot net @ 2007-03-16 15:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from pluto at agmk dot net  2007-03-16 15:39 -------
(In reply to comment #18)

> The patch needs testcases,

i have a testcase but my tcl/autogen/dejagnu crashes
with magic `spawn failed' message :/

e.g.:

(...)
Executing on host:
/home/users/pluto/rpm/BUILD/gcc-4.2-20070307/builddir/gcc/xgcc
-B/home/users/pluto/rpm/BUILD/gcc-4.2-20070307/builddir/gcc/
-O0  -w -fno-show-column -c  -o 20000105-1.o
/home/users/pluto/rpm/BUILD/gcc-4.2-20070307/gcc/testsuite/gcc.c-torture/compile/20000105-1.c
   (timeout = 300)

compiler exited with status -1
output is:
spawn failed
FAIL: gcc.c-torture/compile/20000105-1.c  -O0  (test for excess errors)
Excess errors:
spawn failed


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2007-03-16 15:22 ` pluto at agmk dot net
@ 2007-03-16 15:30 ` manu at gcc dot gnu dot org
  2007-03-16 15:39 ` pluto at agmk dot net
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-16 15:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from manu at gcc dot gnu dot org  2007-03-16 15:30 -------
(In reply to comment #17)
> Created an attachment (id=13214)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13214&action=view) [edit]
> extended patch against gcc-4.2
> 

Hi Pawel,

if the bug exists in mainline, the patch should be against mainline (I think
this patch will apply to mainline anyway). The patch needs testcases, and it
should be sent to gcc-patches@gcc.gnu.org.

Also,

+       warning (0, "%q#T has virtual functions and accessible"
+                " non-virtual destructor", t)
should be:
+       warning (OPT_Wnon_virtual_dtor, 
+                "%q#T has virtual functions and accessible"
+                " non-virtual destructor", t)

Also
+                       || DECL_FRIENDLIST( TYPE_MAIN_DECL (t)))))))
should be
+                       || DECL_FRIENDLIST (TYPE_MAIN_DECL (t)))))))

Thanks for the patch.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2007-02-22  2:03 ` pluto at agmk dot net
@ 2007-03-16 15:22 ` pluto at agmk dot net
  2007-03-16 15:30 ` manu at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: pluto at agmk dot net @ 2007-03-16 15:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from pluto at agmk dot net  2007-03-16 15:22 -------
Created an attachment (id=13214)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13214&action=view)
extended patch against gcc-4.2


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2007-02-22  1:10 ` ben at decadent dot org dot uk
@ 2007-02-22  2:03 ` pluto at agmk dot net
  2007-03-16 15:22 ` pluto at agmk dot net
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: pluto at agmk dot net @ 2007-02-22  2:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from pluto at agmk dot net  2007-02-22 02:02 -------
quite better ( modulo coding style ) patch is:

--- class.c.orig        2006-10-12 22:02:53.000000000 +0200
+++ class.c     2007-02-22 02:54:11.888652367 +0100
@@ -5105,15 +5105,15 @@
       tree dtor;

       dtor = CLASSTYPE_DESTRUCTORS (t);
-      /* Warn only if the dtor is non-private or the class has
-        friends.  */
       if (/* An implicitly declared destructor is always public.  And,
             if it were virtual, we would have created it by now.  */
          !dtor
          || (!DECL_VINDEX (dtor)
-             && (!TREE_PRIVATE (dtor)
-                 || CLASSTYPE_FRIEND_CLASSES (t)
-                 || DECL_FRIENDLIST (TYPE_MAIN_DECL (t)))))
+                 && (/* public non-virtual */
+                     (!TREE_PRIVATE (dtor) && !TREE_PROTECTED (dtor))
+                     || (/* or non-public non-virtual with friends */
+                         (TREE_PRIVATE (dtor) || TREE_PROTECTED (dtor))
+                          && (CLASSTYPE_FRIEND_CLASSES (t) || DECL_FRIENDLIST
(TYPE_MAIN_DECL (t)))))))
        warning (0, "%q#T has virtual functions but non-virtual destructor",
                 t);
     }

it correctly warns on B, C and D classes:

struct A {
        virtual void f() = 0;
protected:
        ~A(); // ok.
};

struct B {
        virtual void f() = 0;
        ~B(); // warn! public non-virtual dtor.
};

struct C {
        virtual void f() = 0;
        // warn! implicit public non-virtual dtor.
};

struct D {
        virtual void f() = 0;
private:
        friend class C;
        ~D(); // warn! can be called from class C.
};


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2007-02-22  0:13 ` pluto at agmk dot net
@ 2007-02-22  1:10 ` ben at decadent dot org dot uk
  2007-02-22  2:03 ` pluto at agmk dot net
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: ben at decadent dot org dot uk @ 2007-02-22  1:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from ben at decadent dot org dot uk  2007-02-22 01:10 -------
Pawel: Yes, any friend class or function can call a protected or private
destructor wrongly.  So can members of the class - in fact, even pure virtual
members can, since they may still have definitions!

The current implementation warns whenever any function might be able to call a
non-virtual destructor in a polymorphic class; this results in many false
positives.  False warnings result in programmers disabling the warning, or
paying less attention to warnings, or (in this case) introducing a virtual
destructor for no good reason.  That is why I consider the behaviour a bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2007-02-13 17:20 ` manu at gcc dot gnu dot org
@ 2007-02-22  0:13 ` pluto at agmk dot net
  2007-02-22  1:10 ` ben at decadent dot org dot uk
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: pluto at agmk dot net @ 2007-02-22  0:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from pluto at agmk dot net  2007-02-22 00:13 -------
(In reply to comment #12)
> Already posted as <http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00885.html>,
> with no response. 

this patch doesn't cover one situation:

struct D;
struct C {
        virtual void f() = 0;
protected: // or private
        friend class D;
        ~C();
};

in such case compiler should generate warning, because class D
can delete derived object through the pointer to class C.


-- 

pluto at agmk dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pluto at agmk dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2007-02-13 16:16 ` ben at decadent dot org dot uk
@ 2007-02-13 17:20 ` manu at gcc dot gnu dot org
  2007-02-22  0:13 ` pluto at agmk dot net
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-13 17:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from manu at gcc dot gnu dot org  2007-02-13 17:19 -------
(In reply to comment #12)
> Already posted as <http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00885.html>,
> with no response. 
> 

You need to insist. A week is normally considered an acceptable interval
between pings. You need to bootstrap + regression test.
http://gcc.gnu.org/contribute.html#testing

Short version:
make && make -k check 

Then, compare with the output without your patch.

What I normally do is, for an unpatched tree:
make && (make -k check &> pristine)

then patch and do the same saving the output in another file. Compare the two
outputs (there is a compare tests script in the contrib/ directory).

Of course, this is a very dirty and rough explanation. It is better to read the
docs.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2007-02-13 15:12 ` manu at gcc dot gnu dot org
@ 2007-02-13 16:16 ` ben at decadent dot org dot uk
  2007-02-13 17:20 ` manu at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: ben at decadent dot org dot uk @ 2007-02-13 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from ben at decadent dot org dot uk  2007-02-13 16:16 -------
Already posted as <http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00885.html>,
with no response. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2006-12-08  0:40 ` ben at decadent dot org dot uk
@ 2007-02-13 15:12 ` manu at gcc dot gnu dot org
  2007-02-13 16:16 ` ben at decadent dot org dot uk
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-13 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from manu at gcc dot gnu dot org  2007-02-13 15:12 -------
(In reply to comment #8)
> Created an attachment (id=11520)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11520&action=view) [edit]
> proposed patch (with doc and test changes)
> 

Thanks for the patch. However, formal submissions are sent to
gcc-patches@gcc.gnu.org. An attachment in bugzilla is not considered a formal
submission and it may go unnoticed. Please, consider submitting to
gcc-patches@gcc.gnu.org (and perhaps also adding it to the patch queue:
http://www.dberlin.org/patchdirections.html )


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2006-12-07 21:26 ` dee at pcds dot biz
@ 2006-12-08  0:40 ` ben at decadent dot org dot uk
  2007-02-13 15:12 ` manu at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: ben at decadent dot org dot uk @ 2006-12-08  0:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from ben at decadent dot org dot uk  2006-12-08 00:40 -------
Lawrence: Every class has a destructor. You're talking about classes that have
trivial destructors. Whether a non-virtual destructor is trivial or not has no
bearing on the fact that if an instance of a derived class is destroyed through
a pointer or reference to a base class with a non-virtual destructor, the
result is undefined behaviour.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2006-10-16 15:26 ` mueller at gcc dot gnu dot org
@ 2006-12-07 21:26 ` dee at pcds dot biz
  2006-12-08  0:40 ` ben at decadent dot org dot uk
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: dee at pcds dot biz @ 2006-12-07 21:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from dee at pcds dot biz  2006-12-07 21:25 -------
I'd like to point out that structures containing only pure virtual functions
should not trigger this diagnostic either. Consider the following:

struct IfacFoo
{
   virtual int a() = 0;
   virtual int b() = 0;
};

There is no destructor declared nor do any members exist to necessitate the
implicit creation of one. As of version "4.1.1 20060525 (Red Hat 4.1.1-1)", the
diagnostic message is still emitted in both this case and those with a
protected "dummy" destructor included.


-- 

dee at pcds dot biz changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dee at pcds dot biz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
  2006-03-19 12:21 ` debian-gcc at lists dot debian dot org
  2006-05-27 15:30 ` ben at decadentplace dot org dot uk
@ 2006-10-16 15:26 ` mueller at gcc dot gnu dot org
  2006-12-07 21:26 ` dee at pcds dot biz
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: mueller at gcc dot gnu dot org @ 2006-10-16 15:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mueller at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
           Keywords|                            |patch
   Last reconfirmed|2005-12-11 23:01:26         |2006-10-16 15:26:28
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
  2006-03-19 12:21 ` debian-gcc at lists dot debian dot org
@ 2006-05-27 15:30 ` ben at decadentplace dot org dot uk
  2006-10-16 15:26 ` mueller at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: ben at decadentplace dot org dot uk @ 2006-05-27 15:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ben at decadentplace dot org dot uk  2006-05-27 15:30 -------
Created an attachment (id=11520)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11520&action=view)
proposed patch (with doc and test changes)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
       [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
@ 2006-03-19 12:21 ` debian-gcc at lists dot debian dot org
  2006-05-27 15:30 ` ben at decadentplace dot org dot uk
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 29+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2006-03-19 12:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from debian-gcc at lists dot debian dot org  2006-03-19 12:21 -------
Created an attachment (id=11068)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11068&action=view)
proposed patch

patch, proposed at http://bugs.debian.org/356316


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2011-06-04 16:25 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20020713190601.7302.cesarb@nitnet.com.br>
2004-04-30  0:36 ` [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor pinskia at gcc dot gnu dot org
2004-05-12 15:43 ` bangerth at dealii dot org
2004-05-13 11:26 ` jason at gcc dot gnu dot org
2004-12-09  2:02 ` pinskia at gcc dot gnu dot org
2005-03-20 17:47 ` pinskia at gcc dot gnu dot org
     [not found] <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
2006-03-19 12:21 ` debian-gcc at lists dot debian dot org
2006-05-27 15:30 ` ben at decadentplace dot org dot uk
2006-10-16 15:26 ` mueller at gcc dot gnu dot org
2006-12-07 21:26 ` dee at pcds dot biz
2006-12-08  0:40 ` ben at decadent dot org dot uk
2007-02-13 15:12 ` manu at gcc dot gnu dot org
2007-02-13 16:16 ` ben at decadent dot org dot uk
2007-02-13 17:20 ` manu at gcc dot gnu dot org
2007-02-22  0:13 ` pluto at agmk dot net
2007-02-22  1:10 ` ben at decadent dot org dot uk
2007-02-22  2:03 ` pluto at agmk dot net
2007-03-16 15:22 ` pluto at agmk dot net
2007-03-16 15:30 ` manu at gcc dot gnu dot org
2007-03-16 15:39 ` pluto at agmk dot net
2007-03-16 16:14 ` manu at gcc dot gnu dot org
2007-03-20 18:52 ` pluto at agmk dot net
2007-03-20 19:02 ` manu at gcc dot gnu dot org
2007-03-20 19:42 ` patchapp at dberlin dot org
2007-08-20 15:09 ` jason at gcc dot gnu dot org
2007-08-21 10:54 ` cesarb at cesarb dot net
     [not found] <bug-7302-4@http.gcc.gnu.org/bugzilla/>
2011-06-02 21:30 ` redi at gcc dot gnu.org
2011-06-02 21:45 ` manu at gcc dot gnu.org
2011-06-02 21:47 ` manu at gcc dot gnu.org
2011-06-04 16:25 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).