[gnu.g++.bug] G++ 1.34.2 overloaded virtual functions

wedekind@arisia.Xerox.COM (Jerry Wedekind) (04/27/89)

Environment:  g++ 1.34.2, Sun3 OS4.

G++ seems to have a bug with overloaded virtual functions.  In the test case:

    class A {
    public:
        virtual void XXX (int);
    };

    class B : public A {
    public:
        void XXX (int);
        void XXX (char);
    };

It complains:

    "test.h:9: conficting specification deriving virtual function 'void B::XXX (float)'

It should be the case that XXX(int) is virtual in A & B, and XXX is
overloaded in B.  The situation is clear:  if you have an A.XXX(int)
use the virtual function table, and if you call B.XXX, you use the
overloaded function rules & then virtual (if needed).  It doesn't help
to make A.XXX overloaded, since it still complains about any new
overloaded functions in B.

This test case works in g++ 1.32 & Oregon C++.

Is this illegal (and two other compilers are wrong), or is there a
workaround in 1.34.2?

/John

arpa:  JWenn.esae@Xerox.com
uucp:  wedekind@arisia.uucp

tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (04/27/89)

   Date: 26 Apr 89 19:55:32 GMT
   From: arisia!wedekind@lll-winken.llnl.gov  (Jerry Wedekind)
   Organization: Xerox PARC
   Sender: bug-g++-request@prep.ai.mit.edu


   Environment:  g++ 1.34.2, Sun3 OS4.

   G++ seems to have a bug with overloaded virtual functions.  In the test case:

       class A {
       public:
	   virtual void XXX (int);
       };

       class B : public A {
       public:
	   void XXX (int);
	   void XXX (char);
       };

   It complains:

       "test.h:9: conficting specification deriving virtual function 'void B::XXX (float)'

   It should be the case that XXX(int) is virtual in A & B, and XXX is
   overloaded in B.  The situation is clear:  if you have an A.XXX(int)
   use the virtual function table, and if you call B.XXX, you use the
   overloaded function rules & then virtual (if needed).  It doesn't help
   to make A.XXX overloaded, since it still complains about any new
   overloaded functions in B.

   This test case works in g++ 1.32 & Oregon C++.

   Is this illegal (and two other compilers are wrong), or is there a
   workaround in 1.34.2?

   /John

   arpa:  JWenn.esae@Xerox.com
   uucp:  wedekind@arisia.uucp

Some people thought that this should be an error, and cfront
complains, so I made GNU C++ complain.  There will be a flag in
1.35.0, -Woverloaded-virtual which permits this extension.

Michael

rfg@MCC.COM (Ron Guilmette) (04/28/89)

Recently, arisia!wedekind@lll-winken.llnl.gov  (Jerry Wedekind) wrote:
|G++ seems to have a bug with overloaded virtual functions.  In the test case:
|
|    class A {
|    public:
|        virtual void XXX (int);
|    };
|
|    class B : public A {
|    public:
|        void XXX (int);
|        void XXX (char);
|    };
|
|It complains:
|
|    "test.h:9: conficting specification deriving virtual function 'void B::XXX (float)'

I have mentioned this to Michael T. and said that I believe it to be a bug.
Perhaps the fact that other C++ compilers/translators accept this without
error will serve as some confirmation of my view.

// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg

jordan@cs.columbia.edu (Jordan Hayes) (04/28/89)

Ron Guilmette <rfg@MCC.COM> writes:

	I have mentioned this to Michael T. and said that I believe it
	to be a bug.  Perhaps the fact that other C++
	compilers/translators accept this without error will serve as
	some confirmation of my view.

Wow, that'd be neat, but like where does it say that this is correct
behavior?  Just because some Joe Compiler accepts it and "does the
right thing" with it doesn't *necessarily* mean that it's correct for
the language.  Can anyone quote chapter and verse about this subject?
(yes, i've been bitten by this same problem, and was annoyed to have to
declare two virtuals, but is it _correct_ C++?).

/jordan