public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20710] New: g++ should warn when hiding non-virtual method in base class
@ 2005-04-01  8:14 loose at astron dot nl
  2005-07-02  1:00 ` [Bug c++/20710] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: loose at astron dot nl @ 2005-04-01  8:14 UTC (permalink / raw)
  To: gcc-bugs

I was wondering whether it is possible to have GCC produce a warning
whenever a non-virtual method in the base class is hidden by a method in the
derived class. I know this is possible for virtual methods by using
the -Woverload-virtual switch, but I haven't been able to find the
equivalent for non-virtual methods.

For example, I would like GCC to produce a warning about the following code.

$ cat tHide.cc
class A
{
public:
  void f() {}
};

class B : public A
{
public:
  void f(int) {}
};

int main()
{
  A a;
  B b;
  b.f(10);
  a.f();
}

Something like: warning: void A::f() was hidden by void B::f(int)

$ g++ -v -save-temps -Wall -Wextra tHide.cc
Reading specs from /usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ../gcc-3.4.3/configure --prefix=/usr/local/gcc343 --enable-
threads=posix
Thread model: posix
gcc version 3.4.3
 /usr/local/gcc343/libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1plus -E -quiet -v -
D_GNU_SOURCE tHide.cc -mtune=pentiumpro -Wall -Wextra -o tHide.ii
ignoring nonexistent directory "/usr/local/gcc343/lib/gcc/i686-pc-linux-
gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3
 /usr/local/gcc343/lib/gcc/i686-pc-linux-
gnu/3.4.3/../../../../include/c++/3.4.3/i686-pc-linux-gnu
 /usr/local/gcc343/lib/gcc/i686-pc-linux-
gnu/3.4.3/../../../../include/c++/3.4.3/backward
 /usr/local/include
 /usr/local/gcc343/include
 /usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3/include
 /usr/include
End of search list.
 /usr/local/gcc343/libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1plus -fpreprocessed 
tHide.ii -quiet -dumpbase tHide.cc -mtune=pentiumpro -auxbase tHide -Wall -
Wextra -version -o tHide.s
GNU C++ version 3.4.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o tHide.o tHide.s
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD version 
2.13.90.0.18 20030206
 /usr/local/gcc343/libexec/gcc/i686-pc-linux-gnu/3.4.3/collect2 --eh-frame-hdr -
m elf_i386 -dynamic-linker /lib/ld-
linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/gcc343/lib/gcc/i686-pc-
linux-gnu/3.4.3/crtbegin.o -L/usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3 -
L/usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3/../../.. tHide.o -lstdc++ -
lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/gcc343/lib/gcc/i686-pc-linux-
gnu/3.4.3/crtend.o /usr/lib/crtn.o

-- 
           Summary: g++ should warn when hiding non-virtual method in base
                    class
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: loose at astron dot nl
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2005-07-02  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-01  8:14 [Bug c++/20710] New: g++ should warn when hiding non-virtual method in base class loose at astron dot nl
2005-07-02  1:00 ` [Bug c++/20710] " pinskia at gcc dot gnu dot 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).