public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Thomas dot Lange at sun dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/31397]  New: Useful compiler warning missing (virtual functions in derived classes used without 'virtual')
Date: Fri, 30 Mar 2007 09:49:00 -0000	[thread overview]
Message-ID: <bug-31397-14335@http.gcc.gnu.org/bugzilla/> (raw)

When trying to build the OOo code warning-free we turned all useful warnings on
and get rid of them.
But there is one warning that would be really useful missing. It is not
required for code correctness or safety at all, but it would be most useful to
have better understandable code.

What I/we at OOo would like to have is a warning when a when a function in a
derived class is overloaded without specifing 'virtual'. 

This would allow to identify all the cases where this is missing and in the end
it would be clear just be looking at the specific declaration of a class which
functions are virtual and which not. Right now in our sometimes very old code
it is quite troublesome to always go up in the class hierarchy in order to
check this.

Example:
class A
{
  A();
  virtual ~A();
  virtual int f( int x );
};

class B : public A
{
  B( int y );
  ~B();
  int f( int x );
};

It would be nice if there would be warnings for ~B and f not using the
'virtual' keyword. Together with the switch to treat warnings as errors this
would help to produce better understandable code.


-- 
           Summary: Useful compiler warning missing (virtual functions in
                    derived classes used without 'virtual')
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Thomas dot Lange at sun dot com


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


             reply	other threads:[~2007-03-30  9:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-30  9:49 Thomas dot Lange at sun dot com [this message]
2007-03-30 23:43 ` [Bug c++/31397] " fang at csl dot cornell dot edu
2007-04-07 23:58 ` bangerth at dealii dot org
2009-07-08 10:23 ` Thomas dot Lange at sun dot com
2009-07-08 10:30 ` Thomas dot Lange at sun dot com
2009-07-13 11:48 ` jwakely dot gcc at gmail dot com
2009-07-13 11:57 ` Thomas dot Lange at sun dot com
2009-07-13 12:00 ` rguenth at gcc dot gnu dot org
2009-07-13 12:02 ` Thomas dot Lange at sun dot com
2009-07-13 12:07 ` Thomas dot Lange at sun dot com
2009-07-13 16:47 ` jwakely dot gcc at gmail dot com
2009-07-21 10:51 ` jwakely dot gcc at gmail dot com
2009-08-11 14:16 ` jwakely dot gcc at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31397-14335@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).