[Bug c++/123228] Member of protected base is inaccessible despite a friend declaration

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 29 15:00:27 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123228

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Arseniy Orlov from comment #2)
> Created attachment 63174 [details]
> 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.
That sounds right. Assuming the fix passes bootstrap+regression testing
(https://gcc.gnu.org/contribute.html#testing), please do send it to gcc-patches
for review (https://gcc.gnu.org/contribute.html#patches).


More information about the Gcc-bugs mailing list