https://llvm.org/bugs/show_bug.cgi?id=24088
Bug ID: 24088
Summary: inconsistent unqualified lookup for friend declaration
Product: clang
Version: 3.6
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Consider the following code, courtesy of Belloc
(http://stackoverflow.com/q/31348475/2069064):
struct Outer {
void f() { }
class C { };
class Inner {
friend class C;
friend void f();
static const int i = 0;
};
};
void f() { int i = Outer::Inner::i; }
class C { int i = Outer::Inner::i; };
int main() { }
According to [namespace.memdef]/3, "the lookup to determine whether the entity
has been previously declared shall not consider any scopes outside the
innermost enclosing namespace."
There's some confusion as to what "outside" means in this context, but
regardless both GCC and Clang are inconsistent in their interpretation. Either
it means exclusively the innermost enclosing namespace (in which case both ::f
and ::C should be friends) or it just means stop at the innermost enclosing
namespace (in which case both Outer::f and Outer::C should be friends). But in
this case, both GCC and Clang friend ::f and Outer::C, which is a bug in one
direction or the other.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs