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]

Hidden virtual functions



Hi,

Here is a program.
The egcs compiler compiles it without warnings.
The aCC (HP) compiler compiles it with warning.

Is it worth doing the same in the egcs compiler?

        Thanks in advance,
        Alex



//#########################################################
//------------------- C++ code : BEGIN -------------------

// main.C
#include <iostream.h>

class BBB
{
        public :
                virtual void fff (char c) {cout << "BBB : " << c <<
endl;}
                virtual void fff (float f) {cout << "BBB : " << f <<
endl;}
};

class DDD : public BBB  // Line#10
{
        public :
                void fff (char c) {cout << "DDD : " << c << endl;}
};

int main ()
{
DDD     ddd;
char    c1 = 'x';
float   f1 = 456.678;

        ddd.fff (c1);
        ddd.fff (f1);
        return 0;
}

//------------------- C++ code : END ----------------------



//#########################################################
//######### egcs compiler #################################
//#########################################################


//------------------- Compilation Results : BEGIN ---------
% g++ -ancsi -pedantic main.C

--- No warnings ---
--- No errors -----

//------------------- Compilation Results : END -----------


//---------------------------------------------------------

//#########################################################


//#########################################################
//------------------- Running Results : BEGIN -------------

DDD : x
DDD : È

//------------------- Running Results : END ---------------


//#########################################################
//------------------- Compiler & System  ------------------

g++ -v     : gcc version egcs-2.91.57 19980901
             (egcs-1.1 release)

uname -a   : SunOS <nodename> 5.6 Generic_105181-09
             sun4m sparc SUNW,SPARCstation-5

//---------------------------------------------------------

//#########################################################



//#########################################################
//######### aCC compiler ##################################
//#########################################################


//------------------- Compilation Results : BEGIN ---------
% aCC main.C

Warning 652: "/n/s8/homesun8.2/users/alexv/main.C", line 10 # Virtual
function "void BBB::fff(float)" is hidden by "void DDD::fff(char)"; did
you forget to override it?
    class DDD : public BBB
    ^^^^^^^^^

//------------------- Compilation Results : END -----------


//---------------------------------------------------------

//#########################################################


//#########################################################
//------------------- Running Results : BEGIN -------------

DDD : x
DDD : È

//------------------- Running Results : END ---------------


//#########################################################
//------------------- Compiler & System  ------------------

what /bin/aCC
           HP aC++ B3910B A.01.06
           HP aC++ B3910B A.01.01 Support Library

uname -srv : HP-UX B.10.20 A

//---------------------------------------------------------

//#########################################################







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