1 // { dg-do run } 2 // Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> 3 4 // PR c++/12370 5 // Wrong code because of the friend declaration 6 7 template <typename T> struct A 8 { 9 T x; AA10 A(T t) : x(t) {} 11 friend A<int> foo (const A<unsigned>&); 12 }; 13 foo(const A<unsigned> & a)14A<int> foo (const A<unsigned>& a) 15 { 16 A<int> res(a.x); 17 return res; 18 } 19 main()20int main() 21 { 22 return foo(A<unsigned>(0)).x; 23 } 24