This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bad error messages from missing =0 on virtual function decl


Dear GCC Maintainers--

I attatch two files, gcc-non-bug.cpp and gcc-bug.cpp.  They differ in
that the latter is missing a "= 0" after the declaration of a pure
virtual function.  This is wrong, and g++ properly rejects it.  However,
the error message with which it is rejected is utterly incomprehensible
to those of us not lucky enough to understand the internals of GCC:

/tmp/ccLjbuwZ.o: In function `child type_info function':
/tmp/ccLjbuwZ.o(.text+0x45): undefined reference to `parent type_info
function'
/tmp/ccLjbuwZ.o(.text+0x4c): undefined reference to `parent type_info
node'
/tmp/ccLjbuwZ.o: In function `parent::parent(void)':
/tmp/ccLjbuwZ.o(.parent::gnu.linkonce.t.(void)+0x8): undefined reference
to `parent virtual table'
collect2: ld returned 1 exit status

Perhaps this error could be made more understandable?  This file is of
course a cut-down example of a much bigger file in which this bug led me
on a merry chase.

I also attatch the .ii files, just in case...

Thanks,

--CarlF

PS Here is the output of "g++ -v --save-temps gcc-non-bug.cpp":

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs

gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cpp -lang-c++ -v -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__
-Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__
-D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix)
-D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386
-D__i386 -D__i386__ -D__tune_i386__ gcc-non-bug.cpp gcc-non-bug.ii
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-2
 /usr/local/include
 /usr/i386-redhat-linux/include
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cc1plus gcc-non-bug.ii
-quiet -dumpbase gcc-non-bug.cc -version -o gcc-non-bug.s
GNU C++ version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
(i386-redhat-linux) compiled by GNU C version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release).
 as -V -Qy -o gcc-non-bug.o gcc-non-bug.s
GNU assembler version 2.9.5 (i386-redhat-linux) using BFD version
2.9.5.0.22
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/collect2 -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/crtbegin.o
-L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66
-L/usr/i386-redhat-linux/lib gcc-non-bug.o -lstdc++ -lm -lgcc -lc -lgcc
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/crtend.o /usr/lib/crtn.o


class parent {

public:

  virtual void foo();

};


class child : public parent {

public:

  void foo();

};

void child::foo() {
  
}


int main() {
  child c;
  c.foo();
}
# 1 "gcc-bug.cpp"
class parent {

public:

  virtual void foo();

};


class child : public parent {

public:

  void foo();

};

void child::foo() {
  
}


int main() {
  child c;
  c.foo();
}
class parent {

public:

  virtual void foo() = 0;

};


class child : public parent {

public:

  void foo();

};

void child::foo() {
  
}


int main() {
  child c;
  c.foo();
}
# 1 "gcc-non-bug.cpp"
class parent {

public:

  virtual void foo() = 0;

};


class child : public parent {

public:

  void foo();

};

void child::foo() {
  
}


int main() {
  child c;
  c.foo();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]