[LLVMbugs] [Bug 6954] New: Instantiating friend declaration injects friend into namespace scope

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Apr 27 07:53:19 PDT 2010


           Summary: Instantiating friend declaration injects friend into
                    namespace scope
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dgregor at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

If a class template contains a friend function declaration (whose type does not
depend on the class template's template parameters), and we instantiate that
class template twice, the friend function becomes visible when it shouldn't:

cove:clang dgregor$ cat t.cpp
template<typename T>
struct X {
  operator int();
  friend void f(int x);

int array0[sizeof(X<int>)]; 
int array1[sizeof(X<float>)];

void g() {
  f(5); // expected-error{{undeclared identifier 'f'}}
cove:clang dgregor$ clang++ -fsyntax-only t.cpp 
cove:clang dgregor$ g++ -fsyntax-only t.cpp 
t.cpp: In function ‘void g()’:
t.cpp:11: error: ‘f’ was not declared in this scope

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list