https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127672
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:cb095f94da491f4d5e4df92abbc5d55792849e7d commit r16-9732-gcb095f94da491f4d5e4df92abbc5d55792849e7d Author: Marek Polacek <[email protected]> Date: Wed Sep 30 14:02:21 2026 -0400 c++: ICE with -Wsubobject-linkage and function type [PR127672] Here we crash in decl_namespace_context because function types (or pointer-to-data-member types) like void() have no TYPE_MAIN_DECL: decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl)); We got there from the constrain_class_visibility TYPE_FIELDS walk which emits the -Wsubobject-linkage warning. And this test has: namespace { struct P { }; } struct S { void (*f) (P *); }; I'm using OVERLOAD_TYPE_P, inspired by min_vis_r. PR c++/127672 gcc/cp/ChangeLog: * decl2.cc (constrain_class_visibility): Check OVERLOAD_TYPE_P before calling decl_anon_ns_mem_p. gcc/testsuite/ChangeLog: * g++.dg/warn/Wsubobject-linkage-6.C: New test. Reviewed-by: Jason Merrill <[email protected]> (cherry picked from commit 5f9f8711bf791130fd30bc1f04b2097f3ef25f0b)
