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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

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

commit r15-5772-gf93059c82e61d67bc550ba0e3bf915ab763b02c7
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Nov 29 10:19:08 2024 +0100

    gimple-fold: Fix up type_has_padding_at_level_p [PR117065]

    The following testcase used to ICE on the trunk since the clear small
    object if it has padding optimization before my r15-5746 change,
    now it doesn't just because type_has_padding_at_level_p isn't called
    on the testcase.

    Though, as the testcase shows, structures/unions which contain erroneous
    types of one or more of its members can have TREE_TYPE of the FIELD_DECL
    error_mark_node, on which we can crash.

    E.g. the __builtin_clear_padding lowering just ignores those:
                if (TREE_TYPE (field) == error_mark_node)
                  continue;
    and
                    if (ftype == error_mark_node)
                      continue;
    It doesn't matter much what exactly we do for those cases, as we are going
    to fail the compilation anyway, but we shouldn't crash.

    So, the following patch ignores those in type_has_padding_at_level_p.
    For RECORD_TYPE, we already return if !DECL_SIZE (f) which I think should
    cover already the erroneous fields (and we don't use TYPE_SIZE on those).

    2024-11-29  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/117065
            * gimple-fold.cc (type_has_padding_at_level_p) <case UNION_TYPE>:
            Also continue if f has error_mark_node type.

            * gcc.dg/pr117065.c: New test.
  • [Bug middle-end/117065] [15 reg... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to