[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Linker error message is a triumph of misdirection
From: |
Edward Welbourne |
Subject: |
Linker error message is a triumph of misdirection |
Date: |
Tue, 07 Sep 2004 15:41:34 +0200 |
Previously submitted to gccbug, who point out that there is nothing
the compiler can do about it; this is a linker issue; in their system
it was [Bug c++/17338]. The g++-bug report follows. Basic problem is
that the linker's complaint doesn't address the right problem.
Priority is modest. ld --version says
GNU ld version 2.14.90.0.7 20031029 Debian GNU/Linux
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
Eddy.
--
Feed g++ the following erroneous code:
class Base { public: virtual void Method(void) /* = 0 */; }; // missing text
class Derived : public Base { public: virtual void Method(void) {} };
int main(void)
{
Derived thing;
Base *ptr = &thing;
ptr->Method();
return 0;
}
You will get an error message which makes no mention of the actual
problem (no definition of virtual function in base class, nor does the
base class overtly = 0 it):
g++ -Wall virtual.cpp -o virtual
/usr/local/home/eddy/.sys/tmp/ccAtrV2C.o(.gnu.linkonce.t._ZN4BaseC2Ev+0x8): In
function `Base::Base[not-in-charge]()':
: undefined reference to `vtable for Base'
/usr/local/home/eddy/.sys/tmp/ccAtrV2C.o(.gnu.linkonce.r._ZTI7Derived+0x8):
undefined reference to `typeinfo for Base'
collect2: ld returned 1 exit status
The complaint directs me to the (implicit) constructor; I have seen it
attribute this to a line in a header file from a third-party library.
I have seen this (on larger and more complex code) without the message
about typeinfo for Base being absent; only the vtable's absence was
reported. Some users of g++ might not know what a vtable is.
Environment:
System: Linux whorl 2.4.26-1-686-smp #1 SMP Sat May 1 19:17:11 EST 2004 i686
GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i486-linux
--
Summary: Linker error message is a triumph of misdirection
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eddy at opera dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17338
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Linker error message is a triumph of misdirection,
Edward Welbourne <=