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



             Bug #: 57113

           Summary: cannot resolve function in derived class

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: g...@01.crabdance.com





Created attachment 29972

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29972

preprocessed source file



source :



class ClassA

{

public:

    virtual void meth(int n);

    virtual void meth(const char* s, bool q);

};



class ClassB : public ClassA

{

public:

    virtual void meth(int n);

};



void ClassA::meth(int n)

{

}



void ClassA::meth(const char* s, bool q)

{

}



void ClassB::meth(int n)

{

}





int main(int argc, char** argv)

{

    const char* param = "foobar";

    ClassB inst;



    inst.meth(param, false);



    return 0;

}





"gcc -v" :



Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.8.0/lto-wrapper

Target: i686-pc-linux-gnu

Configured with: ./gcc-4.8.0/configure --with-gnu-ld --with-pic --prefix=/usr

--with-local-prefix=/usr/local --sysconfdir=/etc --program-suffix=-4.8.0

--disable-nls --with-system-zlib --enable-shared --enable-__cxa_atexit

--enable-threads=posix --enable-tls --with-__thread --enable-cpp

--enable-languages=c,c++ --enable-version-specific-runtime-libs

Thread model: posix

gcc version 4.8.0 (GCC)





"gcc test.cc -save-temps" :



test.cc: In function 'int main(int, char**)':

test.cc:33:27: error: no matching function for call to 'ClassB::meth(const

char*&, bool)'

     inst.meth(param, false);

                           ^

test.cc:33:27: note: candidate is:

test.cc:23:6: note: virtual void ClassB::meth(int)

 void ClassB::meth(int n)

      ^

test.cc:23:6: note:   candidate expects 1 argument, 2 provided







maybe this is the correct behaviour, but i'd expect it to work



some typecasting let's us call the function w/o trouble:

((ClassA*)&inst)->meth(param, false);





thank you

Reply via email to