static method hides virtual

Andrew Fitzgibbon awf@robots.ox.ac.uk
Sun Apr 25 10:10:00 GMT 1999


  Reading specs from /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.60/specs
  gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)

I'm fairly sure the following is a bug.  The code below prints "bad" unless 
the "static" is deleted.

Paste the code below to reproduce the behaviour.

cat << EOF > bad.cc
#include <iostream.h>

struct UIT { 
  virtual void get()      { cerr << "bad"; }
  AWFSTATIC void get(void*) { cerr << "inconcievably bad"; }
          void p()        { get(); }
};

struct S3d : public UIT {
  void get() { cerr << "ok"; }
};

main()
{
  S3d* s = new S3d;
  s->p(); // Should call S3d::get()   shirley?
}
EOF

egcs -DAWFSTATIC=static bad.cc && ./a.out
# Prints "bad"

egcs -DAWFSTATIC= bad.cc && ./a.out
# Prints "ok"


More information about the Gcc-bugs mailing list