summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/friend2.C
blob: ce5d2b741f5e683b44b7bbeee5756c0011529707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// { dg-do run }
// Origin: Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

// PR c++/12370
// Wrong code because of the friend declaration

template <typename T> struct A
{
    T x;
    A(T t) : x(t) {}
    friend A<int> foo (const A<unsigned>&);
};

A<int> foo (const A<unsigned>& a)
{
    A<int> res(a.x);
    return res;
}

int main()
{
    return foo(A<unsigned>(0)).x;
}