https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126794
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:7af3c499e0006fa7087b677dc635be2c2c6da299 commit r17-5517-g7af3c499e0006fa7087b677dc635be2c2c6da299 Author: Marek Polacek <[email protected]> Date: Tue Oct 6 17:12:43 2026 -0400 c++/reflection: ICE with splice member access on uninstantiated class [PR126794] We ICE in perform_or_defer_access_check on a null binfo of the object type here: struct A { int m{}; }; template <int> struct E : A {}; template <class W> int get(W *o) { return o->[:^^A::m:]; } int main() { return get((E<2> *)0); } The problem is that in tsubst_expr we call finish_non_static_data_member on any FIELD_DECL, but when the FIELD_DECL is coming from o->[:^^A::m:], the object's type may not have been instantiated yet. I think we should just send COMPONENT_REFs with a splice expression down the finish_class_member_access_expr path which has: if (!currently_open_class (object_type) && !complete_type_or_maybe_complain (object_type, object, complain)) return error_mark_node; so it will instantiate the class and create a TREE_BINFO. With that, the dependent_splice_p check should be unreachable. PR c++/126794 gcc/cp/ChangeLog: * pt.cc (tsubst_expr) <case COMPONENT_REF>: Don't call finish_non_static_data_member on a FIELD_DECL of a COMPONENT_REF when COMPONENT_REF_SPLICE_P is set. Don't check dependent_splice_p in an assert. gcc/testsuite/ChangeLog: * g++.dg/reflect/member16.C: Adjust dg-error. * g++.dg/reflect/member25.C: New test. Reviewed-by: Jason Merrill <[email protected]>
