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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Marek Polacek
<[email protected]>:

https://gcc.gnu.org/g:2850078a8b7a4755b0cbdf11be631eda88dd0b28

commit r15-11611-g2850078a8b7a4755b0cbdf11be631eda88dd0b28
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)

Reply via email to