egcs permits me to declare an array of abstract objects

Corey Kosak kosak@cs.cmu.edu
Sun Apr 18 19:36:00 GMT 1999


Why don't I get a compile-time error here?  If cow were a single object
rather than an array, I would get the usual:
     cannot declare variable `cow' to be of type `cow_t'
       since the following virtual functions are abstract:
          void cow_t::f()


% cat test.cc && g++ -v && g++ test.cc && a.out
struct cow_t {
  virtual void f()=0;
};


int main()
{
  cow_t cow[2];
  cow[0].f();
  return 0;
}
Reading specs from /afs/cs.cmu.edu/project/cmcl-kosak/various-gcc/egcs-19990412/i386_linux3/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.18/specs
gcc version egcs-2.93.18 19990412 (gcc2 ss-980929 experimental)
pure virtual method called
IOT trap


More information about the Gcc-bugs mailing list