🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by chatty%FRLRI61.BITNET Thu, 23 Mar 1989 09:22
Strange building of symbols for friends
#1778
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads