[cfe-dev] [Bug] Undefined reference to function template declared friend and defined in template class
suyog sarda
sardask01 at gmail.com
Mon Mar 10 09:07:00 PDT 2014
Hi,
This is regarding g++ test case
g++.old-deja/g++.pt/friend10.C
*template <class T>
void f(T);
template <class U>
class C
{
template <class T>
friend void f(T)
{
C<U> c;
c.i = 3;
}
public :
void g()
{
f(3.0);
}
int i;
};
int main ()
{
f(7);
C<double> c;
c.g();
}*
Here, even when the body of function *f()* is defined, compiler throws
error :
*In function `main':19095.C:(.text+0x16): undefined reference to `void
f<int>(int)'/tmp/19095-fd27b4.o: In function
`C<double>::g()':19095.C:(.text._ZN1CIdE1gEv[_ZN1CIdE1gEv]+0x1b): undefined
reference to `void f<double>(double)'clang-3.5: error: linker command
failed with exit code 1*
I have filed a bug related to this llvm.org/bugs/show_bug.cgi?id=19095
g++ compiles this without any error.
Please help in verifying if above is real bug. In my view this is a bug
since function body has been defined and as it is declared friend it is a
non-member function of class template.
--
With regards,
Suyog Sarda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140310/8eb964b2/attachment.html>
More information about the cfe-dev
mailing list