public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "richard.guenther@gmail.com" <richard.guenther@gmail.com>,
	"jakub@redhat.com" <jakub@redhat.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"siddhesh@gotplt.org" <siddhesh@gotplt.org>,
	"uecker@tugraz.at" <uecker@tugraz.at>
Subject: Re: [V7][PATCH 2/2] Update documentation to clarify a GCC extension [PR77650]
Date: Wed, 24 May 2023 16:57:51 +0000	[thread overview]
Message-ID: <B01A35F7-702F-4700-8626-C6478CA50075@oracle.com> (raw)
In-Reply-To: <6bafc8ee-f029-4e75-8eea-c480bd80eda5@codesourcery.com>

Hi, Joseph,

I modified the gcc/doc/extend.texi per your suggestion as following:

Let me know if you have further comment and suggestion on this patch.

I will send out the V8 of the patch after some testing.

Thanks.

Qing.

============================================

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 6425ba57e88..9aedaa802e0 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1754,7 +1754,7 @@ structure or an element of an array.  (However, these uses are
 permitted by GCC as extensions, see details below.)
 @end itemize
 
-GCC extension accepts a structure containing an ISO C99 @dfn{flexible array
+The GCC extension accepts a structure containing an ISO C99 @dfn{flexible array
 member}, or a union containing such a structure (possibly recursively)
 to be a member of a structure.
 
@@ -1776,10 +1776,9 @@ struct out_flex_union @{ int n; union union_flex flex_data; @};
 In the above, both @code{out_flex_struct.flex_data.data[]} and
 @code{out_flex_union.flex_data.f.data[]} are considered as flexible arrays too.
 
-
 @item
 A structure containing a C99 flexible array member, or a union containing
-such a structure, is the middle field of another structure, for example:
+such a structure, is not the last field of another structure, for example:
 
 @smallexample
 struct flex  @{ int length; char data[]; @};
@@ -1787,12 +1786,12 @@ struct flex  @{ int length; char data[]; @};
 struct mid_flex @{ int m; struct flex flex_data; int n; @};
 @end smallexample
 
-In the above, @code{mid_flex.flex_data.data[]} has undefined behavior.
-Compilers do not handle such case consistently, Any code relying on
-such case should be modified to ensure that flexible array members
-only end up at the ends of structures.
+In the above, accessing a member of the array @code{mid_flex.flex_data.data[]}
+might have undefined behavior.  Compilers do not handle such a case
+consistently.   Any code relying on this case should be modified to ensure
+that flexible array members only end up at the ends of structures.
 
-Please use warning option  @option{-Wflex-array-member-not-at-end} to
+Please use the warning option @option{-Wflex-array-member-not-at-end} to
 identify all such cases in the source code and modify them.  This warning
 will be on by default starting from GCC 15.
 @end itemize



> On May 19, 2023, at 5:12 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> 
> On Fri, 19 May 2023, Qing Zhao via Gcc-patches wrote:
> 
>> +GCC extension accepts a structure containing an ISO C99 @dfn{flexible array
> 
> "The GCC extension" or "A GCC extension".
> 
>> +@item
>> +A structure containing a C99 flexible array member, or a union containing
>> +such a structure, is the middle field of another structure, for example:
> 
> There might be more than one middle field, and I think this case also 
> includes where it's the *first* field - any field other than the last.
> 
>> +@smallexample
>> +struct flex  @{ int length; char data[]; @};
>> +
>> +struct mid_flex @{ int m; struct flex flex_data; int n; @};
>> +@end smallexample
>> +
>> +In the above, @code{mid_flex.flex_data.data[]} has undefined behavior.
> 
> And it's not literally mid_flex.flex_data.data[] that has undefined 
> behavior, but trying to access a member of that array.
> 
>> +Compilers do not handle such case consistently, Any code relying on
> 
> "such a case", and "," should be "." at the end of a sentence.
> 
> -- 
> Joseph S. Myers
> joseph@codesourcery.com


      parent reply	other threads:[~2023-05-24 16:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 20:49 [V7][PATCH 0/2]Accept and Handle the case when a structure including a FAM nested in another structure Qing Zhao
2023-05-19 20:49 ` [V7][PATCH 1/2] Handle component_ref to a structre/union field including flexible array member [PR101832] Qing Zhao
2023-05-19 23:11   ` Bernhard Reutner-Fischer
2023-05-24 14:09     ` Qing Zhao
2023-05-25  5:41       ` Bernhard Reutner-Fischer
2023-05-25 15:21         ` Qing Zhao
2023-05-19 20:49 ` [V7][PATCH 2/2] Update documentation to clarify a GCC extension [PR77650] Qing Zhao
2023-05-19 21:12   ` Joseph Myers
2023-05-24 13:05     ` Qing Zhao
2023-05-24 16:57     ` Qing Zhao [this message]

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=B01A35F7-702F-4700-8626-C6478CA50075@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=keescook@chromium.org \
    --cc=richard.guenther@gmail.com \
    --cc=siddhesh@gotplt.org \
    --cc=uecker@tugraz.at \
    /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).