<div dir="ltr"><div>Hi,<br><br></div>This is regarding g++ test case <br><h3><span style="font-weight:normal">g++.old-deja/g++.pt/friend10.C</span></h3><pre><i>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();
}</i></pre> <div><div><br></div><div>Here, even when the body of function <i>f()</i> is defined, compiler throws error :<br><br><i>In function `main':<br>19095.C:(.text+0x16): undefined reference to `void f<int>(int)'<br>
/tmp/19095-fd27b4.o: In function `C<double>::g()':<br>19095.C:(.text._ZN1CIdE1gEv[_ZN1CIdE1gEv]+0x1b): undefined reference to `void f<double>(double)'<br>clang-3.5: error: linker command failed with exit code 1</i><br>
<br></div><div>I have filed a bug related to this <a href="http://llvm.org/bugs/show_bug.cgi?id=19095">llvm.org/bugs/show_bug.cgi?id=19095</a><br><br></div><div>g++ compiles this without any error.<br></div><div><br></div>
<div>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.<br></div><div><br>-- <br>With regards,<br>
Suyog Sarda<br>
</div></div></div>