[LLVMbugs] [Bug 24088] New: inconsistent unqualified lookup for friend declaration
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 10 13:38:33 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: barry.revzin at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150710/eb74615f/attachment.html>
More information about the llvm-bugs
mailing list