[Bug c++/124241] [reflection] internal compiler error: in friend_accessible_p, at cp/search.cc:817
chzn at mail dot ustc.edu.cn
gcc-bugzilla@gcc.gnu.org
Sun Apr 26 15:21:58 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124241
--- Comment #5 from chzn at mail dot ustc.edu.cn <chzn at mail dot ustc.edu.cn> ---
I found out how the BUG occors:
for public members, it's always accessible.
for private members, it's accessible iff form friend.
but for protected members, we should reject following:
> class B { protected: int i; };
> class D : public B { void f(B& b) { b.i = 0; } };//reject
by following code in protected_accessible_p at cp/search.cc:730
> if (DECL_NONSTATIC_MEMBER_P (decl)
> && !DERIVED_FROM_P (derived, otype))
it only considered that it can inherit from base class, ignored it can be
injected from anonymous union or unnamed struct.
Here is my new patch:
https://gcc.gnu.org/pipermail/gcc-patches/2026-April/714865.html
More information about the Gcc-bugs
mailing list