From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailrelay.tugraz.at (mailrelay.tugraz.at [129.27.2.202]) by sourceware.org (Postfix) with ESMTPS id A19BA38AA249 for ; Wed, 10 Apr 2024 18:25:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A19BA38AA249 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=tugraz.at Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tugraz.at ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A19BA38AA249 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.27.2.202 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712773533; cv=none; b=E72gA3fO0wqYZd+jn0b9qnSIMt0MWIHFVFqZBU243pWWAcwq1GHNsSFEUEhLnMwszqVJcLen+RqMz3usg1cyVuAFGR8N1k3ZfT0hmUkxQgF2KIGETFBQ1/IIUDyfBdFrAvOndXUU3N0Nmt+aoUzSSuLQuNC6BXobUsmKbo042Y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712773533; c=relaxed/simple; bh=tGAz/mbv90q75YnB0rD5z25I4v4KReFxYWyXHUaW6e4=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=bUbSsdybIb1YQoSvbByFuYa1y0w5v/Q0ltZmVMZJQ1wDz1d19pN87dRP3gNfolfBE3iR789zfomoa6/KYgWLGHzOsHjBrBmJ8jQeLz7HSrGfYDjro5N1zLM9x3W3gutFdQuqR1a1HbBB705d3CnByDFcQ12ksl21tgMxZB6Awys= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [192.168.0.221] (84-115-223-216.cable.dynamic.surfer.at [84.115.223.216]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4VFB864lt3z3wgC; Wed, 10 Apr 2024 20:25:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1712773512; bh=ASktmPOsgn9b5jy95K29Waca+JMU2kl2cHMgX/NARZ0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EXhpnlQiqC7ZKBxlMCX/bzpM4PO1W1Jx6SAWtk0NOes5Ejqeg40IUaHmlNNo/sSoV MuT9sBjP8s416nTYOqnwqUofcAf/Hq5O8jA7TYmpFk7xHFjkStf1f1mCH4VR3trvlg UckPUmB8D/bz23kwWgl3TTxK+q+VbU9SYRlg2s/M= Message-ID: <7516d9f96d842f9316b7623b6851ee32caf74264.camel@tugraz.at> Subject: Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896) From: Martin Uecker To: Joseph Myers , Qing Zhao Cc: richard.guenther@gmail.com, siddhesh@gotplt.org, keescook@chromium.org, isanbard@gmail.com, gcc-patches@gcc.gnu.org Date: Wed, 10 Apr 2024 20:25:09 +0200 In-Reply-To: References: <20240329160703.4012941-1-qing.zhao@oracle.com> <20240329160703.4012941-2-qing.zhao@oracle.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-TUG-Backscatter-control: G/VXY7/6zeyuAY/PU2/0qw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Am Mittwoch, dem 10.04.2024 um 17:35 +0000 schrieb Joseph Myers: > On Fri, 29 Mar 2024, Qing Zhao wrote: >=20 > > + /* Issue error when there is a counted_by attribute with a different > > + field as the argument for the same flexible array member field. = */ >=20 > There's another case of this to consider, though I'm not sure where best= =20 > to check for it (Martin might have suggestions) - of course this case wil= l=20 > need testcases as well. >=20 > Suppose, as allowed in C23, a structure is defined twice in the same=20 > scope, but the two definitions of the structure use inconsistent=20 > counted_by attributes. I'd say that, when the declarations are in the= =20 > same scope (thus required to be consistent), it should be an error for th= e=20 > two definitions of what is meant to be the same structure to use=20 > incompatible counted_by attributes (even though the member declarations= =20 > are otherwise the same). I think the right place could be comp_types_attributes in attributes.cc. It may be sufficient to set the affects_type_identify flag. This should then give a redefinition error as it should do for "packed". >=20 > In C23 structures defined with the same tag in different scopes are=20 > compatible given requirements including compatible types for correspondin= g=20 > elements. It would seem most appropriate to me for such structures with= =20 > incompatible counted_by attributes to be considered *not* compatible type= s=20 > (but it would be valid to define structures with the same tag, different= =20 > scopes, and elements the same except for counted_by - just not to use the= m=20 > in any way requiring them to be compatible). Another option might be to warn about the case when those types are then used together in a way where they are required to be compatible. Then comp_types_attributes would have to return 2. Martin >=20 > > +The @code{counted_by} attribute may be attached to the C99 flexible ar= ray > > +member of a structure. It indicates that the number of the elements o= f the > > +array is given by the field "@var{count}" in the same structure as the >=20 > As noted previously, the "" quotes should be removed there (or replaced b= y=20 > ``'' quotes). >=20