[Bug c++/123228] Member of protected base is inaccessible despite a friend declaration
arseny.orlow at yandex dot ru
gcc-bugzilla@gcc.gnu.org
Sun Dec 28 00:19:25 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123228
--- Comment #2 from Arseniy Orlov <arseny.orlow at yandex dot ru> ---
Created attachment 63174
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63174&action=edit
Issue patch-file
As I understood, the problem is that when checking member accessibility
recursively in cp/search.cc in dfs_walk_once_accessible_r the compiler checks
it from the class that is currently searched for that member rather than from
the class where that private member is actually used:
```
if (!scope
|| TREE_CODE (scope) == NAMESPACE_DECL
|| !is_friend (BINFO_TYPE (binfo), scope))
continue;
```
So I believe that the attached fix is sufficient for this issue.
I may send it to gcc-patches@gcc.gnu.org as well, if necessary.
More information about the Gcc-bugs
mailing list