public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "foom at fuhm dot net" <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, 06 Jul 2022 19:30:32 +0000	[thread overview]
Message-ID: <bug-101836-4-N8vGvX58F3@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

--- Comment #36 from James Y Knight <foom at fuhm dot net> ---
(In reply to Kees Cook from comment #34)
> > Great. Adding that flag, and eliminating the -fstrict-flex-arrays=3 option
> > from this proposal would be good.
> 
> Hmm? No, -fstrict-flex-arrays=3 is still needed (because it changes compiler
> _behavior_, e.g. for proper FORTIFY coverage or trailing arrays, etc).

There is no purpose served by writing a struct member `int x[0];` other than to
create a FAM. Zero-length arrays are not permitted by the C standard, but are a
GCC compiler extension explicitly for the purpose of creating a FAM. This is
entirely unlike `int x[1];` or `int x[10];` which of course have a primary
meaning as a concrete array size...

If the linux kernel doesn't want to allow `int x[0];` FAMs, then prohibit them
entirely using -Werror=zero-length-array (once it's implemented).

  parent reply	other threads:[~2022-07-06 19:30 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
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 [this message]
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-N8vGvX58F3@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).