egcs-ss-970825: template function linking problem

Jonathan Larmour JLarmour@origin-at.co.uk
Mon Sep 1 09:31:00 GMT 1997


At 21:14 29/08/97 -0300, Alexandre Oliva wrote:
>Jonathan Larmour writes:
>
>> template <class T> void problem_fn(T &obj);
>
>> //  printf("%p\n", &problem_fn); // Uncomment this line and it stops
linking
>
>Besides gcc failing to instantiate the template it decided to use,
>there's no way to find out which template function it should have
>used, so an error should have been flagged at compile-time.

Is that true? Remember the linking error I got _did_ have the correct type
in i.e. int, which implies gcc knew exactly which type to use, and it was
only the instantiation which failed:
Undefined                       first referenced
 symbol                             in file
problem_fn(int &)                   /var/tmp/cca0008o1.o

>The correct syntax would be to refer to &problem_fn<int>, but we still
>can't do that in gcc, AFAIK.

Specifying the type exactly slightly removes the point of templates though!

>Another way to accomplish this is to declare:
>
>void (*f)(int&) = problem_fn;
>
>then:
>
>printf("%p\n", f);

This didn't work either when I tried it :-(. (Or do you mean, if the
instantiation problem was fixed?).

Jonathan L.

Origin UK,323 Cambridge Science Park,Cambridge,England. Tel: +44(1223)423355
-------[ It is impossible to enjoy idling thoroughly unless one has ]-------
----------------[ plenty of work to do - Jerome K. Jerome ]-----------------
Help fight spam! http://spam.abuse.net/  These opinions are all my own fault




More information about the Gcc-bugs mailing list