public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108522] [12/13 Regression] ICE in tree-object-size when struct has VLA
Date: Tue, 24 Jan 2023 18:27:04 +0000	[thread overview]
Message-ID: <bug-108522-4-PtqBfRIodx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108522-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
           Priority|P3                          |P2
   Target Milestone|---                         |12.3

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
At least for backports one option can be punt (give the constant maximum or
minimum) when variable length structures are involved, almost nobody uses them
(with the exception of Ada but then _FORTIFY_SOURCE=3 isn't on) and they are
quite a mess to support.
Otherwise, one needs to make sure to use TREE_OPERAND (t, 2) of COMPONENT_REF
if non-NULL.
On the above testcase one can see:
  _3 = &s.1_9->b{off: _1};
  _12 = __builtin_dynamic_object_size (_3, 1);
That {off: _1} in there means COMPONENT_REF's last operand isn't NULL, but is
SSA_NAME _1.  That contains something that should be used instead of
DECL_FIELD_OFFSET if specified, because in DECL_FIELD_OFFSET you'll see a
VAR_DECL that contained that value during gimplification, but isn't maintained
later on.
tree-object-size.cc currently uses byte_position, which is ok if last
COMPONENT_REF's operand is NULL, otherwise it should be
byte_from_pos (TREE_OPERAND (component_ref, 2), DECL_FIELD_BIT_OFFSET (field));
where field is TREE_OPERAND (component_ref, 1).

  parent reply	other threads:[~2023-01-24 18:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 16:52 [Bug tree-optimization/108522] New: [Regression 12/13] " siddhesh at gcc dot gnu.org
2023-01-24 16:53 ` [Bug tree-optimization/108522] " siddhesh at gcc dot gnu.org
2023-01-24 18:27 ` jakub at gcc dot gnu.org [this message]
2023-01-24 18:28 ` [Bug tree-optimization/108522] [12/13 Regression] " jakub at gcc dot gnu.org
2023-01-25  0:47 ` cvs-commit at gcc dot gnu.org
2023-01-26 12:21 ` cvs-commit at gcc dot gnu.org
2023-02-07 20:03 ` [Bug tree-optimization/108522] [12 " cvs-commit at gcc dot gnu.org
2023-02-07 20:03 ` cvs-commit at gcc dot gnu.org
2023-02-07 20:05 ` siddhesh 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-108522-4-PtqBfRIodx@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).