llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

dejagnu test fails to compile with clang g++.old-deja/g++.pt/friend13.C

Open llvmbot opened this issue 15 years ago • 3 comments

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.

llvmbot avatar Aug 26 '11 23:08 llvmbot

https://godbolt.org/z/hGbnfvYGj behavior changed on trunk bisects to 2e78e25f3e5d in https://github.com/llvm/llvm-project/pull/216555

hongtaihu avatar Oct 11 '26 14:10 hongtaihu

All implementation accept this as well: https://godbolt.org/z/xb6ajK4bK

shafik avatar Oct 11 '26 19:10 shafik

3. https://godbolt.org/z/hGbnfvYGj behavior changed on trunk bisects to 2e78e25 in #216555

I think this case is covered by the PR testing.

shafik avatar Oct 11 '26 19:10 shafik