public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/101378] Negative DW_AT_data_member_location
Date: Tue, 10 May 2022 08:21:32 +0000	[thread overview]
Message-ID: <bug-101378-4-eV6LoKOdtD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101378-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r10-10652-gb7f30978be64fb7029698c8a3c4f4435d32f8097
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Nov 11 10:14:04 2021 +0100

    dwarf2out: Fix up field_byte_offset [PR101378]

    For PCC_BITFIELD_TYPE_MATTERS field_byte_offset has quite large code
    to deal with it since many years ago (see it e.g. in GCC 3.2, although it
    used to be on HOST_WIDE_INTs, then on double_ints, now on offset_ints).
    But that code apparently isn't able to cope with members with empty class
    types with [[no_unique_address]] attribute, because the empty classes have
    non-zero type size but zero decl size and so one can end up from the
    computation with negative offset or offset 1 byte smaller than it should
be.
    For !PCC_BITFIELD_TYPE_MATTERS, we just use
        tree_result = byte_position (decl);
    which seems exactly right even for the empty classes or anything which is
    not a bitfield (and for which we don't add DW_AT_bit_offset attribute).
    So, instead of trying to handle those no_unique_address members in the
    current already very complicated code, this limits it to bitfields.

    stor-layout.c PCC_BITFIELD_TYPE_MATTERS handling also affects only
    bitfields, twice it checks DECL_BIT_FIELD and once DECL_BIT_FIELD_TYPE.

    As discussed, this patch uses DECL_BIT_FIELD_TYPE check, because
    DECL_BIT_FIELD might be cleared for some bitfields with bitsizes
    multiple of BITS_PER_UNIT and e.g.
    struct S { int e; int a : 1, b : 7, c : 8, d : 16; } s;
    struct T { int a : 1, b : 7; long long c : 8; int d : 16; } t;

    int
    main ()
    {
      s.c = 0x55;
      s.d = 0xaaaa;
      t.c = 0x55;
      t.d = 0xaaaa;
      s.e++;
    }
    has different debug info with DECL_BIT_FIELD check.

    2021-11-11  Jakub Jelinek  <jakub@redhat.com>

            PR debug/101378
            * dwarf2out.c (field_byte_offset): Do the PCC_BITFIELD_TYPE_MATTERS
            handling only for DECL_BIT_FIELD_TYPE decls.

            * g++.dg/debug/dwarf2/pr101378.C: New test.

    (cherry picked from commit 10db7573014008ff867098206f51012d501ab57b)

  parent reply	other threads:[~2022-05-10  8:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 14:28 [Bug debug/101378] New: " simon.marchi at polymtl dot ca
2021-07-08 17:15 ` [Bug debug/101378] " simon.marchi at polymtl dot ca
2021-07-09 14:38 ` alves.ped at gmail dot com
2021-07-09 14:50 ` alves.ped at gmail dot com
2021-11-09 13:24 ` redi at gcc dot gnu.org
2021-11-09 13:34 ` redi at gcc dot gnu.org
2021-11-09 14:21 ` rguenth at gcc dot gnu.org
2021-11-09 14:24 ` jakub at gcc dot gnu.org
2021-11-09 14:31 ` pedro at palves dot net
2021-11-09 14:49 ` pedro at palves dot net
2021-11-09 16:46 ` pedro at palves dot net
2021-11-11  9:16 ` cvs-commit at gcc dot gnu.org
2021-11-29  8:49 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:21 ` cvs-commit at gcc dot gnu.org [this message]
2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101378-4-eV6LoKOdtD@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).