<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/159424>159424</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[c++][Modules] Member variable of non-exported type has inaccessible hidden friend with defaulted comparison inside namespace
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
The following two valid translation units
```c++
export module a;
namespace n {
struct monostate {
friend auto operator==(monostate, monostate) -> bool = default;
};
export struct a {
friend auto operator==(a, a) -> bool = default;
monostate m;
};
} // namespace n
```
```c++
export module b;
import a;
namespace n {
auto b() -> void {
a() == a();
}
} // namespace n
```
causes clang to fail to compile with
```console
In file included from /app/b.cpp:3:
a.cpp:10:47: error: invalid operands to binary expression ('monostate' and 'monostate')
10 | friend auto operator==(a, a) -> bool = default;
| ^
b.cpp:8:6: note: in defaulted equality comparison operator for 'a' first required here
8 | a() == a();
| ^
b.cpp:8:6: warning: equality comparison result unused [-Wunused-comparison]
8 | a() == a();
| ~~~~^~~~~~
1 warning and 1 error generated.
```
See it live: https://godbolt.org/z/TvWs7osPs
This is basically the same as https://github.com/llvm/llvm-project/issues/123815 except instead of qualifying the call site with the namespace of the outer type, we are calling from within the namespace. I suspect this is also the same issue as https://github.com/llvm/llvm-project/issues/133720
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVU2P4ygQ_TXkUurIxvbYPvjgnnSkOYy00rY057Ipx6wIeAAnnT3kt6_A-dqe3Z1ZNULC4IJ6r15RoHNyp4kaVjyzYrPC2Y_GNgIPUjhvNK06I07N60gwGKXMUeod-KOBAyopwFvUTqGXRsOspXcsaUP_lCy9Z_w59KSlt8lYD3sjZkWALHteTDXuyU3YE2hg5WXReTv3wVgb59HT7U89WElaAM7egJnIojeWZZvQeXWzZ_wzPExqeGLZC3TGKGDZBgQNOCt_wVB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