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++/64445] New: virtual functions polymorphism


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64445

            Bug ID: 64445
           Summary: virtual functions polymorphism
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nagl46 at web dot de

Created attachment 34364
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34364&action=edit
example of described bug

A base class "base" has two virtual functions

virtual void Y( float xx );
virtual void Y( int xx);

A new class "ext" that inherits from base class re-implements the function

virtual void Y( float xx );

Calling function Y(float) on a pointer "base *" pointing to an ext instance
results in a call to "base::Y(int)".

I would expect a call to the "ext::Y(float)" function. Is it a bug or is it my
mistake?

It's the same behavior in gcc 4.7.2 and gcc 5.0.0.


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