public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom Kunert <tom@rp168.urz.tu-dresden.de>
To: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Cc: egcs@cygnus.com
Subject: Re: Template mangling bug in egcs-2.90.16
Date: Mon, 17 Nov 1997 08:12:00 -0000	[thread overview]
Message-ID: <Pine.LNX.3.96.971117163642.10130A-100000@rp168.urz.tu-dresden.de> (raw)
In-Reply-To: <vyz67pr25id.fsf@issan.informatik.uni-dortmund.de>

On 17 Nov 1997, Andreas Schwab wrote:

> In the following example the function f1 is referenced under the name
> "f1(int)", but it should be "A<int> f1<int>(int)".
> 
> $ cat template.cc
> template <class X>
> struct A
> {
>   X x;
>   friend A f1 (X);
> };
> 
> template <class X> A<X> f1 (X) { A<X> a; return a; }
> template <class X> A<X> f2 (const A<X>& a) { return f1 (a.x); }
> 
> template A<int> f1 (int);
> template A<int> f2 (const A<int>&);
> $ gcc -c template.cc
> $ nm -C template.o
> 00000000 ? __FRAME_BEGIN__
>          U f1(int)
> 00000000 T A<int> f1<int>(int)
> 00000012 T A<int> f2<int>(A<int> const &)
> 00000000 t gcc2_compiled.

Obviously the compiler sees two different functions f1(1) : One is the
instantiation of a template and one is an ordinary function. According
to the DWP these functions can coexist, the overload-resolution rules
prefer the normal function. 
The friend declaration in the example is regarded as function, not as
template, so it is undefined (U). Any call to f1(int) will result in a
linker error: f1(int) not defined.
The question is, whether the compiler is allowed to regard the friend
declaration as an ordinary function. I think, this should be a function
template and there is a bug in egcs. (See DWP Nov. 96, 14.3.5)

Thomas Kunert <tom@rp168.urz.tu-dresden.de>



  reply	other threads:[~1997-11-17  8:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-17  2:12 Andreas Schwab
1997-11-17  8:12 ` Tom Kunert [this message]
1997-11-17 12:30   ` Alexandre Oliva
     [not found]   ` <or67prihnu.fsf.cygnus.egcs@grupiara.dcc.unicamp.br>
1997-11-17 18:11     ` Jason Merrill
     [not found] ` <Pine.LNX.3.96.971117163642.10130A-100000.cygnus.egcs@rp168.urz.tu-dresden.de>
1997-11-17 13:18   ` Jason Merrill
1997-11-17 23:08     ` Tom Kunert
1997-11-17 23:16       ` Jason Merrill

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=Pine.LNX.3.96.971117163642.10130A-100000@rp168.urz.tu-dresden.de \
    --to=tom@rp168.urz.tu-dresden.de \
    --cc=egcs@cygnus.com \
    --cc=schwab@issan.informatik.uni-dortmund.de \
    /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).