public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94050] [10 Regression] C++ ABI change on armv7hl-linux-gnueabi since r10-1302
       [not found] <bug-94050-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-09 14:22 ` jakub at gcc dot gnu.org
  2020-03-09 14:34 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-09 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
commit r10-7089-g8475f2902a2e2ca5f7ace8bc5265bd1a815dda20
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Mar 5 14:07:25 2020 -0500

    c++: Fix ABI issue with alignas on armv7hl [PR94050]

    The static_assert in the following test was failing on armv7hl because
    we were disregarding the alignas specifier on Cell.  BaseShape's data
    takes up 20B on 32-bit architectures, but we failed to round up its
    TYPE_SIZE.  This happens since the
    <https://gcc.gnu.org/ml/gcc-patches/2019-06/msg01189.html>
    patch: here, in layout_class_type for TenuredCell, we see that the size
    of TenuredCell and its CLASSTYPE_AS_BASE match, so we set

      CLASSTYPE_AS_BASE (t) = t;

    While TYPE_USER_ALIGN of TenuredCell was 0, because finalize_type_size
    called from finish_record_layout reset it, TYPE_USER_ALIGN of its
    CLASSTYPE_AS_BASE still remained 1.  After we replace it, it's no longer
    1.  Then we perform layout_empty_base_or_field for TenuredCell and since
    TYPE_USER_ALIGN of its CLASSTYPE_AS_BASE is now 0, we don't do this
    adjustment:

      if (CLASSTYPE_USER_ALIGN (type))
        {
          rli->record_align = MAX (rli->record_align, CLASSTYPE_ALIGN (type));
          if (warn_packed)
            rli->unpacked_align = MAX (rli->unpacked_align, CLASSTYPE_ALIGN
(type));
          TYPE_USER_ALIGN (rli->t) = 1;
        }

    where rli->t is BaseShape.  Then finalize_record_size won't use the
    correct rli->record_align and therefore
      /* Round the size up to be a multiple of the required alignment.  */
      TYPE_SIZE (rli->t) = round_up (unpadded_size, TYPE_ALIGN (rli->t));
    after this we end up with the wrong size.

    Since the original fix was to avoid creating extra copies for LTO
    purposes, I think the following fix should be acceptable.

            PR c++/94050 - ABI issue with alignas on armv7hl.
            * class.c (layout_class_type): Don't replace a class's
            CLASSTYPE_AS_BASE if their TYPE_USER_ALIGN don't match.

            * g++.dg/abi/align3.C: New test.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/94050] [10 Regression] C++ ABI change on armv7hl-linux-gnueabi since r10-1302
       [not found] <bug-94050-4@http.gcc.gnu.org/bugzilla/>
  2020-03-09 14:22 ` [Bug c++/94050] [10 Regression] C++ ABI change on armv7hl-linux-gnueabi since r10-1302 jakub at gcc dot gnu.org
@ 2020-03-09 14:34 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-09 14:34 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-09 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-94050-4@http.gcc.gnu.org/bugzilla/>
2020-03-09 14:22 ` [Bug c++/94050] [10 Regression] C++ ABI change on armv7hl-linux-gnueabi since r10-1302 jakub at gcc dot gnu.org
2020-03-09 14:34 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).