2.95.1 fails to complain

JDonner jdonnerATschedsys.com
Tue Sep 14 07:46:00 GMT 1999


Hi,

  I pass a static member Create taking no arguments 
to the constructor of some object.  The syntax used is 
wrong, it should have an & in front of it.

  When there is a second non-static member Create
with a different signature declared, 2.95.1 correctly 
complains.  Without the second, irrelevant (that I can 
see) Create function 2.95.1 takes the bad syntax without 
comment.  Is this a bug?

Jeff

//#define RIGHTLY_COMPLAINS 1
class ObjClass;

class Obj {};

class ObjClass : public Obj
{
public:
  ObjClass(Obj *(pfnCreate)() = 0);
};

class D : public Obj
{
public:
  static Obj* Create();
#if RIGHTLY_COMPLAINS
  int Create(int n);
#endif

  static const ObjClass classD;
};

ObjClass::ObjClass(Obj* (pfnCreate)()) {}
// Compiler should complain here, (should be &D::Create)
const ObjClass D::classD(D::Create);

Obj* D::Create() { return 0; }
#if RIGHTLY_COMPLAINS
int D::Create(int n) { return 0; }
#endif

int main()
{
  return 0;
}


More information about the Gcc-bugs mailing list