Path: utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!comp.vuw.ac.nz!andrew
From: andrew@comp.vuw.ac.nz (Andrew Vignaux)
Newsgroups: gnu.g++.bug
Subject: An old problem with "Hello world"
Message-ID: <8809250559.AA01798@comp.vuw.ac.nz>
Date: 25 Sep 88 05:59:16 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Comp Sci, Victoria University, Wellington, New Zealand.
Lines: 38

Hi, I have a problem with GNU C++ version 1.22.1 (vax) compiled by GNU C
version 1.22 with GNU as and ld++.  This is not a bug report -- it should
be old news :-).

The problem has been reported in bug-g++ but I missed any fix (if it was
posted) before I had to unsubscribe due to the volume.  I would like to
know the way this has been fixed in later versions.

hello.cc
	#include 
	main()
	{
	    cout << "Hello world\n";
	}

/usr/local/lib/gcc-c++ /tmp/cc020557.cpp -quiet -dumpbase hello.cc -noreg \
                       -version -o /tmp/cc020557.s

produces no output [GUESS ALERT] because the constructor for cout is not
being run.  This is because the only symbol connecting "hello.o" with
"stream.o" in "libg++.a" is the Common symbol "cout" and the loader does
not force stream.o to be linked in this case.  The ld++ ctor collecter
misses the fact that __GLOBAL_$I$stream_cc needs to be included in the
___CTOR_LIST__.  Things work fine if you write:
	    cout << "You are number " << 6;
because ld++ has to link in stream.o.  Ok, ok... you knew all that :-)

My questions is "what was the fix".  If it can be described in a few
paragraphs of english or a few pages of code I would love to see it.  I
already know that the best way to solve my problem is to upgrade to the
latest version.

Please respond by email as I am no longer subscribed to the list/group.

Thanks.

Andrew.
------------------------------------------------------------------------------
Domain address: andrew@comp.vuw.ac.nz   Path address: ...!uunet!vuwcomp!andrew