From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 998E53858C2D for ; Fri, 16 Jun 2023 21:35:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 998E53858C2D 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,248,1681200000"; d="scan'208";a="10136143" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 16 Jun 2023 13:35:34 -0800 IronPort-SDR: qvfqhABA/CLSWui+eHscSORddxuhUZ4MAqZUmgiUytDbMXzcb5jySCJkfTzdI5KxAkB1v/yfTB DAw2CUTj9HXyFAwhGnkWVGX66EMw+92UQ49z1I/OBE/pZkpNqAWZz61oF5EJX/MlD8YMMMSATZ wyEQCanLys0tV8s/bWyFZpaVzqIkPXttS/FU+xN6+rKAdUF78QOroahG6Fy9cmpQK37ugGlCY5 OOOjYYxK+L6JzMZP90On0TeWFmHcc7cIf6sTOr4VGijHpJwzjIR7f5qdvCY5tL7GGv0wdQeWkF pa4= Date: Fri, 16 Jun 2023 21:35:29 +0000 From: Joseph Myers To: Qing Zhao CC: Martin Uecker , Qing Zhao via Gcc-patches , "richard.guenther@gmail.com" , "jakub@redhat.com" , "keescook@chromium.org" , "siddhesh@gotplt.org" , "isanbard@gmail.com" Subject: Re: [V1][PATCH 1/3] Provide element_count attribute to flexible array member field (PR108896) In-Reply-To: <35B5E4D7-DCC5-4058-BC26-ADD669AC725D@oracle.com> Message-ID: References: <20230525161450.3704901-1-qing.zhao@oracle.com> <20230525161450.3704901-2-qing.zhao@oracle.com> <28BEA1DA-5277-493D-8C85-1C204AD1B70F@oracle.com> <4F824ECC-6ACC-434A-8887-0CB44D0B3CDA@oracle.com> <5616c54-65c8-c3c-714-7fef81501a60@codesourcery.com> <6068bad0-a0c4-3f41-6640-9d3b062794f@codesourcery.com> <35B5E4D7-DCC5-4058-BC26-ADD669AC725D@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-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3106.0 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, 16 Jun 2023, Qing Zhao via Gcc-patches wrote: > > So for > > > > struct foo { int c; int buf[(struct { int d; }){ .d = .c }]; }; > > > > one knows during parsing that the .d is a designator > > and that .c is not. > > Therefore, the above should be invalid based on this rule since .c is > not a member in the current structure. What do you mean by "current structure"? I think two different concepts are being conflated: the structure *being initialized* (what the C standard calls the "current object" for a brace-enclosed initializer list), and the structure *being defined*. The former is what's relevant for designators. The latter is what's relevant for the suggested new syntax. And .c *is* a member of the structure being defined in this example. Those two structure types are always different, except for corner cases with C2x tag compatibility (where an object of structure type might be initialized in the middle of a redefinition of that type). -- Joseph S. Myers joseph@codesourcery.com