[llvm-bugs] [Bug 40233] New: friend definition makes function visible when it should not

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 5 12:16:45 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40233

            Bug ID: 40233
           Summary: friend definition makes function visible when it
                    should not
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rhainin1 at binghamton.edu
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Based on this stackoverflow question:
https://stackoverflow.com/q/54055638/1013719

gcc correctly rejects the following, while clang accepts:

```
class Cls {
    friend void func(int) { }
    friend void ::func(int);
};
```

with:

```
error: ‘void func(int)’ has not been declared within ‘::’
     friend void ::func(int);
                 ^~
note: only here as a ‘friend’
     friend void func(int) { }
                 ^~~~
```

The friend definition should not make `func` visible by
http://eel.is/c++draft/namespace.memdef#3.sentence-2

> The friend declaration does not by itself make the name visible to unqualified lookup or qualified lookup.

-- 
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/20190105/34e8df5c/attachment.html>


More information about the llvm-bugs mailing list