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

--- Comment #15 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:7199cf12773b1429c19cdd5b69950b2f09470e64

commit r17-457-g7199cf12773b1429c19cdd5b69950b2f09470e64
Author: Marek Polacek <[email protected]>
Date:   Thu May 7 16:38:34 2026 -0400

    c++/reflection: fixes for comparing reflections [PR125208]

    This fixes two bugs:

    1) crash in cp_tree_equal when comparing reflections with binfos;
    cp_tree_equal doesn't handle those.  We're coming from
    lookup_template_class -> spec_hasher::equal -> comp_template_args
    -> cp_tree_equal.  We should use compare_reflections in cp_tree_equal.

    2) the fix for 1) revealed that compare_reflections is buggy when
    comparing two aliases: we shouldn't fall back to same_type_p
    because given

       using A = int;
       using B = int;

    ^^A != ^^B should hold.

            PR c++/125208

    gcc/cp/ChangeLog:

            * reflect.cc (compare_reflections): Use == when comparing two
            aliases.
            * tree.cc (cp_tree_equal) <case REFLECT_EXPR>: Use
            compare_reflections.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/alias3.C: New test.
            * g++.dg/reflect/bases_of5.C: New test.

    Reviewed-by: Patrick Palka <[email protected]>

Reply via email to