From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id A96F83858C41 for ; Fri, 19 May 2023 21:12:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A96F83858C41 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.00,177,1681200000"; d="scan'208";a="5898996" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 19 May 2023 13:12:20 -0800 IronPort-SDR: 5fL6UD0y9P+KiQ7MHjF4YKHwKk5MXx4lYAk6wITYV6XNcDi2q4OscPaLwAJrgTn2IGzAvtxX9p IR/9I7O+4uzF9vjWq7maeL5XnQ1WuytcZGGv+anWRrhcwFEdxVL0QwKossT5Q32rQ6vdeidikt Y0yzivUePfzsSw/TjBBQ5M5HopdZfORgWl7dkPT45JpuAOmUGfG9TOZ/VOKH4Ai5T4INeIRlfc m+YNEh5C/txWx2eK/GyfdArAF4AhVi1jx1qYbdEs56Z0+FFduWdRQZxRqnE568D9HY7kCj/VHE EqE= Date: Fri, 19 May 2023 21:12:15 +0000 From: Joseph Myers To: Qing Zhao CC: , , , , , Subject: Re: [V7][PATCH 2/2] Update documentation to clarify a GCC extension [PR77650] In-Reply-To: <20230519204948.237791-3-qing.zhao@oracle.com> Message-ID: <6bafc8ee-f029-4e75-8eea-c480bd80eda5@codesourcery.com> References: <20230519204948.237791-1-qing.zhao@oracle.com> <20230519204948.237791-3-qing.zhao@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3106.6 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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