public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "siddhesh at gotplt dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/101836] __builtin_object_size(P->M, 1) where M is an array and the last member of a struct fails
Date: Wed, 13 Oct 2021 03:11:11 +0000	[thread overview]
Message-ID: <bug-101836-4-a0uQ5TlSip@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101836-4@http.gcc.gnu.org/bugzilla/>

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

Siddhesh Poyarekar <siddhesh at gotplt dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |siddhesh at gotplt dot org

--- Comment #5 from Siddhesh Poyarekar <siddhesh at gotplt dot org> ---
Vim explicitly disables _FORTIFY_SOURCE to keep its use of 1-sized trailing
arrays:

https://github.com/vim/vim/issues/5581

so either they haven't tested with more recent gcc or they're hitting a corner
case where __builtin_object_size does return the subscript value for the
trailing member.

I inherited the __builtin_object_size behaviour in
__builtin_dynamic_object_size to remain consistent with current behaviour:

ok:  sizeof(*working) == 24
ok:  sizeof(working->c) == 16
ok:  __builtin_object_size(working, 1) == -1
ok:  __builtin_object_size(working->c, 1) == 16
ok:  __builtin_dynamic_object_size(working, 1) == -1
ok:  __builtin_dynamic_object_size(working->c, 1) == 16
ok:  sizeof(*broken) == 24
ok:  sizeof(broken->c) == 16
ok:  __builtin_object_size(broken, 1) == -1
WAT: __builtin_object_size(broken->c, 1) == -1 (expected 16)
ok:  __builtin_dynamic_object_size(broken, 1) == -1
WAT: __builtin_dynamic_object_size(broken->c, 1) == -1 (expected 16)


However in theory if the pass can see the allocation, it should be able to
build the right expression for object size.

I'm updating the patchset to meld the two passes into one and I could add
-fstrict-flex-arrays as one of the patches to make this stricter.

  parent reply	other threads:[~2021-10-13  3:11 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 23:25 [Bug c/101836] New: " kees at outflux dot net
2021-08-09 23:34 ` [Bug c/101836] " pinskia at gcc dot gnu.org
2021-08-09 23:35 ` pinskia at gcc dot gnu.org
2021-08-10  1:19 ` kees at outflux dot net
2021-10-13  2:11 ` msebor at gcc dot gnu.org
2021-10-13  2:11 ` [Bug middle-end/101836] " msebor at gcc dot gnu.org
2021-10-13  3:11 ` siddhesh at gotplt dot org [this message]
2022-05-26 16:34 ` qinzhao at gcc dot gnu.org
2022-05-27  1:45 ` siddhesh at gcc dot gnu.org
2022-05-27 14:27 ` qinzhao at gcc dot gnu.org
2022-05-27 21:01 ` kees at outflux dot net
2022-05-27 21:08 ` kees at outflux dot net
2022-05-27 21:15 ` kees at outflux dot net
2022-06-08 14:09 ` qinzhao at gcc dot gnu.org
2022-06-08 15:37 ` kees at outflux dot net
2022-06-08 16:06 ` qinzhao at gcc dot gnu.org
2022-06-10 20:15 ` qinzhao at gcc dot gnu.org
2022-06-10 20:24 ` qinzhao at gcc dot gnu.org
2022-06-11  8:21 ` kees at outflux dot net
2022-06-13 14:48 ` msebor at gcc dot gnu.org
2022-06-13 18:12 ` kees at outflux dot net
2022-06-13 22:27 ` msebor at gcc dot gnu.org
2022-06-14  0:00 ` kees at outflux dot net
2022-06-14  5:09 ` siddhesh at gcc dot gnu.org
2022-06-14  5:21 ` siddhesh at gcc dot gnu.org
2022-06-14  7:25 ` jakub at gcc dot gnu.org
2022-06-14 15:00 ` qinzhao at gcc dot gnu.org
2022-06-14 15:39 ` siddhesh at gcc dot gnu.org
2022-06-14 16:02 ` qing.zhao at oracle dot com
2022-06-14 16:17 ` jakub at gcc dot gnu.org
2022-06-14 21:03 ` qinzhao at gcc dot gnu.org
2022-06-14 21:12 ` jakub at gcc dot gnu.org
2022-06-25  0:52 ` foom at fuhm dot net
2022-06-27 14:01 ` qinzhao at gcc dot gnu.org
2022-07-06 16:16 ` foom at fuhm dot net
2022-07-06 16:49 ` kees at outflux dot net
2022-07-06 17:53 ` qinzhao at gcc dot gnu.org
2022-07-06 19:30 ` foom at fuhm dot net
2022-07-06 19:46 ` foom at fuhm dot net
2022-07-06 20:01 ` qinzhao at gcc dot gnu.org
2022-07-06 20:05 ` qinzhao at gcc dot gnu.org
2022-07-22 22:33 ` isanbard at gmail dot com
2022-07-23  1:57 ` kees at outflux dot net
2022-10-07 17:44 ` cvs-commit at gcc dot gnu.org
2022-12-21 20:47 ` qinzhao at gcc dot gnu.org
2023-06-21 19:47 ` qinzhao 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-101836-4-a0uQ5TlSip@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).