Issue 159424
Summary [c++][Modules] Member variable of non-exported type has inaccessible hidden friend with defaulted comparison inside namespace
Labels new issue
Assignees
Reporter davidstone
    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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to