Topic: Cfront 2.1 bug?


Author: rantonov@isis.cs.du.edu (Roumen Antonov)
Date: Sun, 26 Apr 92 19:57:09 GMT
Raw View
Hello!
I'm compiling a C++ program and getting this message:

$ CC -c nm.cxx
"nm.cxx", line 4: redeclaration of __ad__9BaseClassFR9BaseClass
Compilation failed
$ dem __ad__9BaseClassFR9BaseClass
__ad__9BaseClassFR9BaseClass == BaseClass::operator&(BaseClass&)


Here is the code:

********************* nm.hxx ****************************
class ResutOfAddition;
class ResultOfAnd;

class BaseClass                                // base of all classes
{
protected:
   virtual int Value()  const = 0;
public:
   ResutOfAddition operator+(BaseClass&);    // result of operation +
   ResultOfAnd operator&(BaseClass&);        // result of operation &

   friend ClassA;
   friend ClassB;
   friend ResutOfAddition;
   friend ResultOfAnd;
};

class ClassA : public BaseClass         // first derived class
{
protected:
   ClassA();                             // default constructor
   void Get(ClassA*);                    // exactly what is says
   int Value() const;
public:
   virtual ~ClassA();

   friend ClassB;
   friend BaseClass;
   friend ResutOfAddition;
   friend ResultOfAnd;
};

class ClassB : public ClassA             // a second class, derived from
{                                        // the first one
public:
   ClassB(int, int);
   ClassB(BaseClass&);
   ClassB(ClassB& ca) { Get(&ca); }
};

class ResutOfAddition : public BaseClass
{
protected:
   BaseClass* bc1;                           // pointers to summands
   BaseClass* bc2;
   ResutOfAddition(BaseClass* oper1, BaseClass* oper2) : bc1(oper1),bc2(oper2) {}
   int Value() const;

   friend BaseClass;
};

class ResultOfAnd : public ResutOfAddition // use the construction above
{
   ResultOfAnd(BaseClass* oper1, BaseClass* oper2)
      : ResutOfAddition(oper1,oper2) {}
   friend BaseClass;
   int Value() const;
}; // end of nm.hxx





************************* nm.cxx ***********************************
#include "nm.hxx"


 ResultOfAnd BaseClass::operator&(BaseClass& bc)
  { return ResultOfAnd(this, &bc); }


************************* end **************************************



What I am doing wrong or it's a cfront bug?  My working environment:

 Sun SPARCstation 1;
 SunOS Release 4.1.1;
 AT&T C++ Translator 2.1.03;

Please understand that this has been extracted from a larger program
and in order to locate the error I've cut out most of the things
including data members, member functions and other classes. That's why
the classes above might seem pretty useless.

Many thanks in advance!

R.
**********************************************************************
*              Roumen Antonov (eeantono@uk.ac.swan.pyr)              *
*====================================================================*
*    Department of Electrical &                                      *
*     Electronic Engineering,        Voice: +44 792 205678(ext.4715) *
*  University College of Swansea     FAX:   +44 792 295613           *
*     Swansea, United Kingdom                                        *
**********************************************************************