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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:ea162107bb376f5ffa18bbda70e14b47bc338070

commit r12-9478-gea162107bb376f5ffa18bbda70e14b47bc338070
Author: Jan Hubicka <j...@suse.cz>
Date:   Fri Aug 12 16:25:28 2022 +0200

    Fix invalid devirtualization when combining final keyword and anonymous
types

    this patch fixes a wrong code issue where we incorrectly devirtualize to
    __builtin_unreachable.  The problem occurs in combination of anonymous
    namespaces and final keyword used on methods.  We do two optimizations here
     1) when reacing final method we cut the search for possible new targets
     2) if the type is anonymous we detect whether it is ever instatiated by
        looking if its vtable is referred to.
    Now this goes wrong when thre is an anonymous type with final method that
    is not instantiated while its derived type is.  So if 1 triggers we need
    to make 2 to look for vtables of all derived types as done by this patch.

    Bootstrpaped/regtested x86_64-linux

    Honza

    gcc/ChangeLog:

    2022-08-10  Jan Hubicka  <hubi...@ucw.cz>

            PR middle-end/106057
            * ipa-devirt.cc (type_or_derived_type_possibly_instantiated_p): New
            function.
            (possible_polymorphic_call_targets): Use it.

    gcc/testsuite/ChangeLog:

    2022-08-10  Jan Hubicka  <hubi...@ucw.cz>

            PR middle-end/106057
            * g++.dg/tree-ssa/pr101839.C: New test.

    (cherry picked from commit 0f2c7ccd14a29a8af8318f50b8296098fb0ab218)

Reply via email to