public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57113] New: cannot resolve function in derived class
@ 2013-04-29 13:48 gcc at 01 dot crabdance.com
  2013-04-29 14:12 ` [Bug c++/57113] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: gcc at 01 dot crabdance.com @ 2013-04-29 13:48 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: gcc@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


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

* [Bug c++/57113] cannot resolve function in derived class
  2013-04-29 13:48 [Bug c++/57113] New: cannot resolve function in derived class gcc at 01 dot crabdance.com
@ 2013-04-29 14:12 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-29 14:12 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-29 14:12:45 UTC ---
(In reply to comment #0)
> maybe this is the correct behaviour, but i'd expect it to work

This is the correct behaviour, search the web for "name hiding"


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

end of thread, other threads:[~2013-04-29 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-29 13:48 [Bug c++/57113] New: cannot resolve function in derived class gcc at 01 dot crabdance.com
2013-04-29 14:12 ` [Bug c++/57113] " redi at gcc dot gnu.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).