<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115350>115350</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Name lookup of friend names is wrong on clang-cl
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
csimon-bambecksystems
</td>
</tr>
</table>
<pre>
Names introduced as friends do not participate in name lookup [as explained here on cpprefererence](https://en.cppreference.com/w/cpp/language/namespace#Namespaces), so the problem with the following ill-formed code:
```
class foo {
friend class bar;
using baz = bar; // Error! Name lookup does not find bar.
};
```
is the name `bar` has not been introduced for name-lookup purposes. MSVC acceps it (that's their problem) but weirdly, clang-cl accepts it and does not warn about a "microsoft extension." I can reproduce it on godbolt with either x86 msvc v19.latest or clang-cl 18.1.0 as the compiler. I know that clang-cl accepts some non-standard name lookup for class templates but this is not a class template, just a regular class. Fun story: I wrote a whole boatload of classes relying on this, uh, "idiom" that I thought I discovered, and I was feeling so good about myself. Then I confidently fed it to another compiler, just another clang with different configuration actually, and *sound of world crashing down.*
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxkVEFvqzgQ_jXOZRQEJgnJgUP7upF62F52tXdjD-BX40EeE5r99SsDafveSpEDjP3NN983HsVsO49Yi-OzOL7s1BR7CrVmO5DfN2poUL_znSMOvGvI3Os3NSCD9TGQmTQaUAxtsOgNgyHwFGFUIVptRxURrAevBgRH9D6NII7PigE_RqesRwM9BgTyoMcxYIsBA3qN4vgi5LmPcWRRPgl5FfKKPvvc5DVmmgYhr7OQVz2OQl6d8t2kOhTymhLyqDQKWb49nlnIi5A_gAlijzAGahwOMNvYLx9aco5m6zuwzu1bCgMa0GQwMchfRP5YT_n2W161U8zQEoGontdPsOkBa6xRQZSfoYlTikb9C6J82WIAa4nwRwgUhCzg7ZtkhpAXWVvrTTqRbUSql0_c30itq-WlsEV-ccp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