🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1778

Strange building of symbols for friends

#1778
From: chatty%FRLRI61.BITNET
Date: Thu, 23 Mar 1989 09:22
63 lines
1695 bytes
Our g++ 1.33 shows a strange behaviour with non-overloaded friend functions
which have previously been declared as external : depending on the context,
it builds a normal symbol (like _foo), or a long one (like _foo_VOID), which
leads to undefined symbols when linking.

Here is the shortest example we found :

::::::::::::::
foo.h
::::::::::::::
extern void foo ();

class A {
friend void foo ();
};


::::::::::::::
foo.cc
::::::::::::::
#include "foo.h"

void foo ()
{
}


::::::::::::::
bar.cc
::::::::::::::
#include "foo.h"

main ()
{
        foo ();
}

% g++ -c foo.cc bar.cc
% g++ -o bar foo.o bar.o
Undefined symbols:
 _foo

% nm foo.o bar.o

foo.o:
00000000 T _foo_VOID              <---------
00000000 t gcc_compiled.                   |
                                           |--- ??????
bar.o:                                     |
         U _foo               <-------------
00000000 T _main
00000000 t gcc_compiled.

That code is perhaps wrong, but I think it would deserve a warning, at least.

I forgot : g++ does the same on SUN3, SUN4, and HP9000s300.



        Stephane CHATTY                       chatty@lri.lri.fr
           L.R.I                              chatty@frlri61.bitnet
    Universite de Paris-Sud
Technical Details
Message-ID: <8903230922.AA22734@lri.lri.fr>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CUNYVM.CUNY.EDU!chatty%FRLRI61.BITNET

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CUNYVM.CUNY.EDU!chatty%FRLRI61.BITNET
From: chatty%FRLRI61.BITNET@CUNYVM.CUNY.EDU
Newsgroups: gnu.g++.bug
Subject: Strange building of symbols for friends
Message-ID: <8903230922.AA22734@lri.lri.fr>
Date: 23 Mar 89 09:22:26 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 63