Bug in using overloaded functions in derived classes

Lloyd J. Lewins llewins@west.raytheon.com
Tue May 1 12:07:00 GMT 2001


The attached is straight out of the ISO standard (14882:1998E) 7.3.3, page 
119, and should compile ok. However, errors are received.
Also, the warning on line 3 and 10 is incorrect -- B::f(char) is not hidden 
by D::f(int). But B::h(int) is hidden by D::h(int) and should get
a warning.

g++ -v -Wall -Woverloaded-virtual -ansi -pedantic -c -o test.o test.cc
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/specs
gcc version 2.95.2-6 19991024 (cygwin experimental)
 /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/cpp.exe -lang-c++ -v -D__GNUC__=2 
-D__
GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -trigraphs -D__STRICT_ANSI__ 
-D__i386
__ -D__386__ -D__i386 -D_X86=1 -D__STDC__=1 
-D__stdcall=__attribute__((__stdcall
__)) -D__cdecl=__attribute__((__cdecl__)) 
-D__declspec(x)=__attribute__((x)) -D_
_i386 -Asystem(winnt) -Acpu(i386) -Amachine(i386) -D__EXCEPTIONS -Wall 
-Woverloa
ded-virtual -pedantic -remap -Acpu(i386) -Amachine(i386) -D__i386 
-D__i386__ -D_
_i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__CYGWIN32__ 
-D__CYGWIN__ -Du
nix -D__unix__ -D__unix -isystem /usr/local/include -idirafter /usr/include 
-D_W
IN32 -DWINNT -idirafter /usr/include/w32api test.cc 
/cygdrive/c/TEMP/ccQqoAYP.ii

GNU CPP version 2.95.2-6 19991024 (cygwin experimental) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/../../../../include/g++-3
 /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/include
 /usr/include
 /usr/include/w32api
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/cc1plus.exe 
/cygdrive/c/TEMP/ccQqoAYP.
ii -quiet -dumpbase test.cc -Wall -Woverloaded-virtual -pedantic -ansi 
-version
-o /cygdrive/c/TEMP/cc29OLdy.s
GNU C++ version 2.95.2-6 19991024 (cygwin experimental) (i686-pc-cygwin) 
compile
d by GNU C version 2.95.2-6 19991024 (cygwin experimental).
test.cc:17: cannot adjust access to `void B::f(char)' in `struct D'
test.cc:10:   because of local method `void D::f(int)' with same name
test.cc:17: cannot adjust access to `void B::g(int)' in `struct D'
test.cc:13:   because of local method `void D::g(char)' with same name
test.cc:17: cannot adjust access to `void B::h(int)' in `struct D'
test.cc:16:   because of local method `void D::h(int)' with same name
test.cc:3: warning: `B::f(char)' was hidden
test.cc:10: warning:   by `D::f(int)'



Lloyd J. Lewins
Raytheon Co.,
llewins@west.raytheon.com
+1 (310) 647-8832
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-c++
Size: 300 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20010501/4349d265/attachment.bin>


More information about the Gcc-bugs mailing list