public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: "Her, Il" <il.her@hp.com>, Ian Lance Taylor <iant@google.com>,
	       "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: Undefined reference to template function ...
Date: Wed, 01 Jun 2011 13:23:00 -0000	[thread overview]
Message-ID: <BANLkTimgR8u4DyOkPmi_MibOQ9=KKEgiUA@mail.gmail.com> (raw)
In-Reply-To: <20110601084446.GQ13140@axel>

On Wed, Jun 1, 2011 at 1:44 AM, Axel Freyn <axel-freyn@gmx.de> wrote:
> Hi
>
> On Wed, Jun 01, 2011 at 01:03:03AM +0000, Her, Il wrote:
>> Yes, it is compiled well with gcc 3.4.6,
>> but it doesn't work with gcc 4.1.2
>
> Strange -- I just tried with 3.4.6 on x86_64, configured as
> ../gcc-3.4.6/configure --prefix=/tmp/gcc_test/install --disable-multilib
> Thread model: posix
> gcc version 3.4.6
>
> your testcase gives  (after removing the erroneous ";" in sub.cpp )
>
> /tmp/ccGJf1zv.o: In function `main':
> /tmp/gcc_test/main.cpp:9: undefined reference to `Base<TEST>::dump(TEST&)'
> /tmp/gcc_test/main.cpp:10: undefined reference to `Base<TEST>::fn(int, int)'
> collect2: ld returned 1 exit status

I just did the same thing on x86_64-unknown-linux-gnu, with the same results.

Looking at the code, I don't see how the results could be anything
else.  You need
to force the template expansion to occur as described on the web page
referenced earlier on the thread.

Also looking at the code, it did not compile, due to the extra semicolon, and I
had to change main.cpp to #include "test.h" rather than "TEST.h".  So I don't
think you tested the exact code you showed us with gcc 3.4.6.

Ian

      reply	other threads:[~2011-06-01 13:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-30  8:32 Her, Il
2011-05-31  8:53 ` Ian Lance Taylor
2011-05-31 12:21   ` Her, Il
2011-05-31 12:44     ` Axel Freyn
2011-05-31 15:29     ` Ian Lance Taylor
2011-06-01  1:03       ` Her, Il
2011-06-01  8:45         ` Axel Freyn
2011-06-01 13:23           ` Ian Lance Taylor [this message]

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='BANLkTimgR8u4DyOkPmi_MibOQ9=KKEgiUA@mail.gmail.com' \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=il.her@hp.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).