llvm-project
llvm-project copied to clipboard
dejagnu test fails to compile with clang g++.old-deja/g++.pt/friend13.C
| Bugzilla Link | 10781 |
| Version | 2.9 |
| OS | Linux |
| Attachments | [g++.old-dejahttps://user-images.githubusercontent.com/60944935/143743752-7958a6bf-4adb-479e-a933-b8d4d7028610.gz) |
| Reporter | LLVM Bugzilla Contributor |
Extended Description
code:
// { dg-do run }
template <class T>
class C;
template <class U>
struct S
{
template <class V>
void f(V v)
{
C<V> cv;
cv.i = 3;
}
};
template <class T>
class C
{
template <class U>
template <class V>
friend void S<U>::f(V);
int i;
};
int main()
{
S<int> si;
si.f(3.0);
S<long> sl;
sl.f('c');
}
compiles with g++ and edg based intel compiler
$ /home/rkotler/build_llvm/install/bin/clang++ /home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:12:10: error:
'i' is a private member of 'C<double>'
cv.i = 3;
^
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:31:6: note:
in instantiation of function template specialization
'S<int>::f<double>' requested here
si.f(3.0);
^
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:24:7: note:
implicitly declared private here
int i;
^
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:12:10: error:
'i' is a private member of 'C<char>'
cv.i = 3;
^
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:33:6: note:
in instantiation of function template specialization
'S<long>::f<char>' requested here
sl.f('c');
^
/home/rkotler/gcc-4.4.6/gcc/testsuite/g++.old-deja/g++.pt/friend13.C:24:7: note:
implicitly declared private here
int i;
^
2 errors generated.
https://godbolt.org/z/hGbnfvYGj behavior changed on trunk bisects to 2e78e25f3e5d in https://github.com/llvm/llvm-project/pull/216555
All implementation accept this as well: https://godbolt.org/z/xb6ajK4bK