public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Anthony Shipman <als@tusc.com.au>
To: egcs@cygnus.com (EGCS discussion list)
Subject: template expansion problem-again
Date: Thu, 30 Apr 1998 08:28:00 -0000	[thread overview]
Message-ID: <199804301528.AA11365@ephor.tusc.com.au> (raw)

I sent this before for egcs 1.0.1.  I have retested it with
1.0.3-prerelease and the problem is still there.  Can anyone tell me if
I am doing something wrong or if this is a compiler bug.


I compile using:

g++ -pipe -gstabs -O0 -g -fno-implicit-templates -o x.o -c x.cc
g++ -pipe -gstabs -O0 -g -o x2.o -c x2.cc
g++ -pipe -gstabs -O0 -g -o x x.o x2.o

and I get

x.cc:13: undefined reference to `__hashtable_iterator<pair<char const *const,
int>, char const *, hash<char const *>, select1st<pair<char const *const, int>
>, equal_to<char const *>, __default_alloc_template<false, 0>
>::operator++(void)'
collect2: ld returned 1 exit status

The sources are shown below.  Using nm, I see that x2.o contains the
constructor for the __hashtable_iterator instance but not the
operator++(void).

If I build x from x.cc using

g++ -pipe -gstabs -O0 -g -o x.o -c x.cc
g++ -pipe -gstabs -O0 -g -o x x.o

then it all works fine. nm on x.o shows the operator++.


x.cc
----------------------------------
#include	<hash_map.h>


typedef hash_map<const char*, int>	MyMap;

int
main()
{
    MyMap	map;

    map["abc"] = 3;
    map["fred"] = 42;

    for(MyMap::iterator iter = map.begin();
	iter != map.end();
	iter++)
    {
	cout << "mymap[" << iter->first << "] = " << iter->second << endl;
    }

    return 0;
}


x2.cc
-----------------------------------
#include	<hash_map.h>

template class hash_map<const char*, int>;

-- 
Anthony Shipman                 "You've got to be taught before it's too late,
TUSC Computer Systems Pty Ltd    Before you are six or seven or eight,
666 Doncaster Rd, Doncaster      To hate all the people your relatives hate,
Melbourne, Australia, 3108       You've got to be carefully taught."  R&H

                 reply	other threads:[~1998-04-30  8:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199804301528.AA11365@ephor.tusc.com.au \
    --to=als@tusc.com.au \
    --cc=egcs@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).