From patchwork Mon Sep 25 18:24:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1839228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RvWVq0L8kz1yp0 for ; Tue, 26 Sep 2023 04:24:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0A61385CCB7 for ; Mon, 25 Sep 2023 18:24:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id ECF3D3858D3C for ; Mon, 25 Sep 2023 18:24:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECF3D3858D3C 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-CSE-ConnectionGUID: EM8Y6MH4SWOhUPPdTDO7sg== X-CSE-MsgGUID: WhsOqwJJT7qR3YY0d/4b1A== X-IronPort-AV: E=Sophos;i="6.03,175,1694764800"; d="scan'208";a="17800082" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 25 Sep 2023 10:24:15 -0800 IronPort-SDR: mD4h8Yh7pLuklulgbRHoiU8xA+WhuYBsnDMrMOcj7vU6HtY8SyrPijy937jffOnat46zUfwV8d pclU7sH0ZBN2A+0ETRy6vu8jQx/dbcDOAkyjCDQJgkSoZcJIYbbJbjcCAy/r+UgyV9/fA9lHHp ++TayavFCs9a0YC3cAXev2VSx9rJyHCWqrZHhwbEI4LKIpFecnB3RAvglxxelfqMm+USKwIYTF 6Zbfd+Fh9QMOwenpUMnD18HKCeIjq8K19yg6dIyS+s9HAU6AtRadgeVNzP4MA5+RjuJa47KWMR Eik= Message-ID: Date: Mon, 25 Sep 2023 20:24:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Improve -Wflex-array-member-not-at-end changes.html wording |Plus: and warning bug? (was: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.) Content-Language: en-US To: Qing Zhao , , CC: References: <20230807142216.1857701-1-qing.zhao@oracle.com> From: Tobias Burnus In-Reply-To: <20230807142216.1857701-1-qing.zhao@oracle.com> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi all, I stumbled over this as I found the wording in the release notes rather unclear.is. First, the following gives only a -pedantic warning and not a -Wflex-array-member-not-at-end: struct t { int b; int x[]; }; struct q { int b; struct t a[2]; int c; }; warning: invalid use of structure with flexible array member [-Wpedantic] If I remove the "[2]", it shows additionally: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] It seems as if it should print latter warning also inside the struct. Qing? Joseph? Thoughts? * * * Secondly, if this is deprecated, shouldn't then the warning enabled by, e.g., -Wall or made otherwise more prominent? (-std=?) - Currently, one either has to find the new flag or use -pedantic. Or is this not really regarded as deprecated? But then (IMHO) we should not really claim so and just add the warning without deprecation. BTW; clang-15 prints the -Wgnu-variable-sized-type-not-at-end warning by default. Joseph, all: Thoughts? * * * Cross ref: The patch adding the new warning is r14-2197-g070a6bf0bdc6761 https://gcc.gnu.org/pipermail/gcc-cvs/2023-June/385730.html (cf. previously in this thread) * * * Regarding the changes.html wording: On 07.08.23 16:22, Qing Zhao via Gcc-patches wrote: > Comparing to the 1st version, the only change is to address Richard's > comment on refering a warning option for diagnosing deprecated behavior. ... > +++ b/htdocs/gcc-14/changes.html > @@ -30,7 +30,18 @@ a work-in-progress.

> >

Caveats

>
    > -
  • ...
  • > +
  • C: > + Support for the GCC extension, a structure containing a C99 flexible array > + member, or a union containing such a structure, is not the last field of > + another structure, is deprecated. Refer to > + > + Zero Length Arrays. ... I find the first sentence difficult to read. What do you think of the following? (It is hard to come up with some good wording.) Tobias PS: C17 has: "A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of a structure with more than one named member may have incomplete array type; such a structure (and any union containing, possibly recursively, a member that is such a structure) shall not be a member of a structure or an element of an array." ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 --- a/htdocs/gcc-14/changes.html +++ b/htdocs/gcc-14/changes.html @@ -31,9 +31,10 @@ a work-in-progress.

    Caveats

    • C: - Support for the GCC extension, a structure containing a C99 flexible array - member, or a union containing such a structure, is not the last field of - another structure, is deprecated. Refer to + Support for the GCC extension that a structure containing a C99 flexible + array (and any union containing a member of such structure) can be a + member of a structure has been deprecated for the case that it is not + the last member. Refer to Zero Length Arrays. Any code relying on this extension should be modifed to ensure that