public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Qing Zhao <qing.zhao@oracle.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 "siddhesh@gotplt.org" <siddhesh@gotplt.org>,
	 "keescook@chromium.org" <keescook@chromium.org>,
	 "Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: [PATCH 1/2] Handle component_ref to a structre/union field including flexible array member [PR101832]
Date: Mon, 6 Feb 2023 09:31:22 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2302060929330.6551@jbgna.fhfr.qr> (raw)
In-Reply-To: <F92E62C7-D427-47B9-85B7-5595378261F9@oracle.com>

On Fri, 3 Feb 2023, Qing Zhao wrote:

> 
> 
> > On Feb 3, 2023, at 2:49 AM, Richard Biener <rguenther@suse.de> wrote:
> > 
> > On Thu, 2 Feb 2023, Qing Zhao wrote:
> > 
> >> 
> >> 
> >>> On Feb 2, 2023, at 8:54 AM, Richard Biener <rguenther@suse.de> wrote:
> >>> 
> >>> On Thu, 2 Feb 2023, Qing Zhao wrote:
> >>> 
> >>>> 
> >>>> 
> > 
> > [...]
> > 
> >>>>>>>> +	return flexible_size_type_p (TREE_TYPE (last));
> >>>>>>> 
> >>>>>>> For types with many members this can become quite slow (IIRC we had
> >>>>>>> bugs about similar walks of all fields in types), and this function
> >>>>>>> looks like it's invoked multiple times on the same type per TU.
> >>>>>>> 
> >>>>>>> In principle the property is fixed at the time we lay out a record
> >>>>>>> type, so we might want to compute it at that time and record the
> >>>>>>> result.
> >>>>>> 
> >>>>>> You mean in FE? 
> >>>>> 
> >>>>> Yes, either in the frontend or in the middle-ends layout_type.
> >>>>> 
> >>>>>> Yes, that?s better and cleaner.
> >>>>>> 
> >>>>>> I will add one more field in the TYPE structure to record this information and check this field during middle end.
> >>>>>> 
> >>>>>> I had the same thought in the beginning, but not sure whether adding a 
> >>>>>> new field in IR is necessary or not, other places in middle end might 
> >>>>>> not use this new field.
> >>>>> 
> >>>>> It might be interesting to search for other code walking all fields of
> >>>>> a type to determine this or similar info.
> >>>> 
> >>>> There is one which is defined in tree.cc but only is referenced in c/c-decl.cc:
> >>>> 
> >>>> /* Determine whether TYPE is a structure with a flexible array member,
> >>>>  or a union containing such a structure (possibly recursively).  */
> >>>> flexible_array_type_p
> >>>> 
> >>>> However, this routine is a little different than the one I tried to add:
> >>>> 
> >>>> In the current routine ?flexible_array_type_p?,  only one level nesting in the structure is accepted, multiple nesting in structure is not permitted.
> >>>> 
> >>>> So, my question is:  shall we accept multiple nesting in structure? i.e.
> >>> 
> >>> If we don't reject the testcase with an error, then yes.
> >> 
> >> Gcc currently accepts the multiple nesting in structure without error.  
> >> So, we will continue to accept such extension as long as the flex array 
> >> is at the end of the structure. At the same time, for the case the flex 
> >> array is in the middle of the structure, issue additional warnings now 
> >> to discourage such usage, and deprecate this case in a future release.
> >> 
> >> Does this sound reasonable? 
> > 
> > Please don't mix several issues - I think the flex array in the
> > middle of a structure is separate and we shouldn't report that
> > as flexible_array_type_p or flexible_size_type_p since the size
> > of the containing structure is not variable.
> Agreed on this.
> 
> My major question here is (for documentation change, sorry for mixing 
> this thread with the documentation change): do we need to document this 
> case together with the case in which struct with flex array is embedded 
> into another structure? (As a GCC extension?)

I think this should be Josephs call - documenting this might
encourage people to use such an extension, even if it's a bad
one we want to get rid of.

Maybe the easiest thing is to come up with a patch documenting it
which we can then turn into a deprecation note depending on this
outcome.

Richard.

  reply	other threads:[~2023-02-06  9:31 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 14:11 [PATCH 0/2]PR101832: Handle component_ref to a structure/union field including flexible array member for builtin_object_size Qing Zhao
2023-01-31 14:11 ` [PATCH 1/2] Handle component_ref to a structre/union field including flexible array member [PR101832] Qing Zhao
2023-02-01 11:41   ` Richard Biener
2023-02-01 14:19     ` Qing Zhao
2023-02-02  8:07       ` Richard Biener
2023-02-02 13:52         ` Qing Zhao
2023-02-02 13:54           ` Richard Biener
2023-02-02 14:38             ` Qing Zhao
2023-02-03  7:49               ` Richard Biener
2023-02-03 13:17                 ` Qing Zhao
2023-02-06  9:31                   ` Richard Biener [this message]
2023-02-06 14:38                     ` Qing Zhao
2023-02-06 23:14                       ` Joseph Myers
2023-02-07 14:54                         ` Qing Zhao
2023-02-07 19:17                           ` Joseph Myers
2023-02-07 19:57                             ` Qing Zhao
2023-02-07 23:37                               ` Joseph Myers
2023-02-08 15:06                                 ` Qing Zhao
2023-02-08 19:09                                   ` Joseph Myers
2023-02-08 19:20                                     ` Siddhesh Poyarekar
2023-02-08 20:51                                       ` Joseph Myers
2023-02-08 22:53                                       ` Qing Zhao
2023-02-08 23:18                                     ` Qing Zhao
2023-02-09 14:40                                       ` Qing Zhao
2023-02-09 16:46                                         ` Kees Cook
2023-02-10 15:25                                           ` Qing Zhao
2023-02-09 10:35                                   ` Richard Biener
2023-02-09 13:44                                     ` Qing Zhao
2023-02-07 15:28                         ` Siddhesh Poyarekar
2023-02-07 15:38                           ` Qing Zhao
2023-02-01 16:48   ` Siddhesh Poyarekar
2023-02-01 18:20     ` Qing Zhao
2023-01-31 14:11 ` [PATCH 2/2] Documentation Update Qing Zhao
2023-02-01 16:55   ` Siddhesh Poyarekar
2023-02-01 18:24     ` Qing Zhao
2023-02-01 18:57       ` Siddhesh Poyarekar
2023-02-01 19:19         ` Qing Zhao
2023-02-02  8:33         ` Richard Biener
2023-02-02 14:31           ` Qing Zhao
2023-02-02 17:05             ` Kees Cook
2023-02-03 15:56               ` Jeff Law
2023-02-03  4:25           ` Siddhesh Poyarekar
2023-02-03 14:52             ` Qing Zhao
2023-02-03 20:55             ` Joseph Myers
2023-02-03 22:38               ` Qing Zhao
2023-05-25  1:22 [V8][PATCH 0/2]Accept and Handle the case when a structure including a FAM nested in another structure Qing Zhao
2023-05-25  1:22 ` [PATCH 1/2] Handle component_ref to a structre/union field including flexible array member [PR101832] Qing Zhao

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=nycvar.YFH.7.77.849.2302060929330.6551@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=keescook@chromium.org \
    --cc=qing.zhao@oracle.com \
    --cc=siddhesh@gotplt.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).