public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17338] New: Linker error message is a triumph of misdirection
@ 2004-09-06 17:26 gcc-bugzilla at gcc dot gnu dot org
  2004-09-07  8:16 ` [Bug c++/17338] " pinskia at gcc dot gnu dot org
  2004-09-07 13:48 ` eddy at opera dot com
  0 siblings, 2 replies; 3+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-09-06 17:26 UTC (permalink / raw)
  To: gcc-bugs


	Feed the compiler 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

	Also present in 3.4.1:

g++-3.4 -Wall    virtual.cpp   -o virtual
/usr/local/home/eddy/.sys/tmp/ccNDFkO3.o(.gnu.linkonce.t._ZN4BaseC2Ev+0x8): In function `Base::Base()':
: undefined reference to `vtable for Base'
/usr/local/home/eddy/.sys/tmp/ccNDFkO3.o(.gnu.linkonce.r._ZTI7Derived+0x8): undefined reference to `typeinfo for Base'
collect2: ld returned 1 exit status

The complaint directs me to the 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.

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

How-To-Repeat:
	When reporting a compiler error, preprocessor output must be included - OK, here it is:
g++ -E virtual.cpp
# 1 "virtual.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "virtual.cpp"
class Base { public: virtual void Method(void) ; };
class Derived : public Base { public: virtual void Method(void) {} };
int main(void)
{
        Derived thing;
        Base *ptr = &thing;
        ptr->Method();
        return 0;
}

-- 
           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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/17338] Linker error message is a triumph of misdirection
  2004-09-06 17:26 [Bug c++/17338] New: Linker error message is a triumph of misdirection gcc-bugzilla at gcc dot gnu dot org
@ 2004-09-07  8:16 ` pinskia at gcc dot gnu dot org
  2004-09-07 13:48 ` eddy at opera dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-07  8:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-07 08:16 -------
no we cannot do this because the error is outputted by ld (which is owned by different people and is 
not part of GCC).  Also the defintion of Base::Method could be in a different translational unit so GCC 
cannot say that it is undefined when compiling to assembly.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17338


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/17338] Linker error message is a triumph of misdirection
  2004-09-06 17:26 [Bug c++/17338] New: Linker error message is a triumph of misdirection gcc-bugzilla at gcc dot gnu dot org
  2004-09-07  8:16 ` [Bug c++/17338] " pinskia at gcc dot gnu dot org
@ 2004-09-07 13:48 ` eddy at opera dot com
  1 sibling, 0 replies; 3+ messages in thread
From: eddy at opera dot com @ 2004-09-07 13:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From eddy at opera dot com  2004-09-07 13:47 -------
Subject: Re:  Linker error message is a triumph of misdirection

> no we cannot do this because the error is outputted by ld (which is
> owned by different people and is not part of GCC).  Also the
> defintion of Base::Method could be in a different translational unit
> so GCC cannot say that it is undefined when compiling to assembly.

You're right, of course; duly forwarded to bug-binutils at gnu dot org.
Sorry to be distracting with mis-directed report ...

(I tried supplying this via bugzilla so I could confirm it as
resolved, but it wanted a password ...)

	Eddy.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17338


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-07 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-06 17:26 [Bug c++/17338] New: Linker error message is a triumph of misdirection gcc-bugzilla at gcc dot gnu dot org
2004-09-07  8:16 ` [Bug c++/17338] " pinskia at gcc dot gnu dot org
2004-09-07 13:48 ` eddy at opera dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).