This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/18223] New: c++ polymorphic functions not seen in child of adt


As shown below, the polymorphic functions in ADT with default implementations
are not recognized in the derived class.  I don't see anything in the spec
ruling out this case, but I'm no guru so maybe this is in fact invalid code.
The number of arguments and their types don't seem to matter, I used an int
and an ADT reference below to rule out automatic type conversions.

An easy workaround is to change the name of the pure virtual function.

Same behaviour occurs on MacOS X (based on GCC 3.1); the output below is
from WinXP/Cygwin.

class ADT
{
public:
    virtual void a(int a) { this->a(*this); }
    virtual void a(ADT& a) = 0;
};


class A : public ADT
{
public:
    virtual void a(ADT& a) { }
};


class B
{
public:
    void b() { A a; a.a(10); }
};


$ gcc -v -Wall -c test.cxx
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --with-
gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --
libexecdir=/usr/sbin --mandir=/usr/share/man --infodir=/usr/share/info --
enable-languages=c,ada,c++,f77,pascal,java,objc --enable-libgcj --enable-
threads=posix --with-system-zlib --enable-nls --without-included-gettext --
enable-interpreter --enable-sjlj-exceptions --disable-version-specific-runtime-
libs --enable-shared --disable-win32-registry --enable-java-gc=boehm --disable-
hash-synchronization --verbose --target=i686-pc-cygwin --host=i686-pc-cygwin --
build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -
D__unix__ -D__unix -idirafter /usr/lib/gcc-lib/i686-pc-
cygwin/3.3.1/../../../../include/w32api -idirafter /usr/lib/gcc-lib/i686-pc-
cygwin/3.3.1/../../../../i686-pc-cygwin/lib/../../include/w32api test.cxx -
D__GNUG__=3 -quiet -dumpbase test.cxx -auxbase test -Wall -version -
o /cygdrive/c/DOCUME~1/Steve/LOCALS~1/Temp/cccVGDp1.s

GNU C++ version 3.3.1 (cygming special) (i686-pc-cygwin)
        compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=80 --param ggc-min-heapsize=94126
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3.1
 /usr/include/c++/3.3.1/i686-pc-cygwin
 /usr/include/c++/3.3.1/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include
 /usr/include
 /usr/include/w32api
End of search list.
test.cxx: In member function `void B::b()':
test.cxx:19: error: no matching function for call to `A::a(int)'
test.cxx:12: error: candidates are: virtual void A::a(ADT&)

-- 
           Summary: c++ polymorphic functions not seen in child of adt
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: szelinka at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]