Hi, this is my first bug report so im sorry if i stuff this up. I have a simple c++ program which can reproduce this. im not sure if this is expected behavior, but i cant find anything solid saying this is expected behavior and it seems strange to me.
#include <stdio.h> class A { public: virtual int funk () { return 1; } }; class B : public A { public: virtual int funk () { return 2; } }; void func (A& a) { printf ("%d\n", a.funk ()); } void func2 (A a) { func (a); } int main () { A a; B b; func (a); func (b); func2 (A()); func2 (B()); } the output is 1 2 1 1 as you can see B's virtual function was not called compiled with g++ derived.cpp -save-temps -O0 -o derived -Wall and im sorry but i cant work out how to attach a file, so i cant add my .ii file. Sorry, i hope this is enough. -- Summary: unable to access virtual functions from derived class passed as a refference Product: gcc Version: 4.2.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: carlchatfield at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37984