[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2011-06-04 Thread redi at gcc dot gnu.org
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


[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2011-06-02 Thread redi at gcc dot gnu.org
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]


[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2011-06-02 Thread manu at gcc dot gnu.org
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.


[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2011-06-02 Thread manu at gcc dot gnu.org
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.


[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-08-21 Thread cesarb at cesarb dot net


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-08-20 Thread jason at gcc dot gnu dot org


--- 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=gccview=revrev=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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-20 Thread pluto at agmk dot net


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-20 Thread manu at gcc dot gnu dot org


--- 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/msg8.html


-- 


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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-20 Thread patchapp at dberlin dot org


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-16 Thread pluto at agmk dot net


--- 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=13214action=view)
extended patch against gcc-4.2


-- 


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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-16 Thread manu at gcc dot gnu dot org


--- 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=13214action=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 [EMAIL PROTECTED]

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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-16 Thread pluto at agmk dot net


--- 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 2105-1.o
/home/users/pluto/rpm/BUILD/gcc-4.2-20070307/gcc/testsuite/gcc.c-torture/compile/2105-1.c
   (timeout = 300)

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


-- 


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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-03-16 Thread manu at gcc dot gnu dot org


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-21 Thread pluto at agmk dot net


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-21 Thread ben at decadent dot org dot uk


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-21 Thread pluto at agmk dot net


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

--- class.c.orig2006-10-12 22:02:53.0 +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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-13 Thread manu at gcc dot gnu dot org


--- 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=11520action=view) [edit]
 proposed patch (with doc and test changes)
 

Thanks for the patch. However, formal submissions are sent to
[EMAIL PROTECTED] An attachment in bugzilla is not considered a formal
submission and it may go unnoticed. Please, consider submitting to
[EMAIL PROTECTED] (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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-13 Thread ben at decadent dot org dot uk


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2007-02-13 Thread manu at gcc dot gnu dot org


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2006-12-07 Thread dee at pcds dot biz


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2006-12-07 Thread ben at decadent dot org dot uk


--- 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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2006-10-16 Thread mueller at gcc dot gnu dot org


-- 

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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2006-05-27 Thread ben at decadentplace dot org dot uk


--- 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=11520action=view)
proposed patch (with doc and test changes)


-- 


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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2006-03-19 Thread debian-gcc at lists dot debian dot org


--- 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=11068action=view)
proposed patch

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


-- 


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



[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2005-03-20 Thread pinskia at gcc dot gnu dot org

--- 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


[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor

2004-12-08 Thread pinskia at gcc dot gnu dot org


-- 
   What|Removed |Added

 Status|REOPENED|NEW


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