From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6ADB8385840C; Thu, 7 Mar 2024 10:53:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ADB8385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709808827; bh=1POIz93FucXDcucKtI9SwFziplckAGUnAddtPGiTfMk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=os3jLrQTIR464oY7aKhs7X/ez+PNszZN+mHdLjtRDohpbXWqbGGhU5VARqGxDAs0T uV5dG9OLHjApNM9IQQOy+Xz3AYS62VchbWAUmQnjSClQQeuhCrxN6bOZaKRoptQo/P 3Undwiuz5YN2SjQ9LG9HYK0Xe6YpbnOFiE1Gvzmo= From: "alx at kernel dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108036] [11/12/13/14 Regression] Spurious warning for zero-sized array parameters to a function Date: Thu, 07 Mar 2024 10:53:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: alx at kernel dot org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108036 --- Comment #9 from Alejandro Colomar --- Hi Lundin! On Thu, Mar 07, 2024 at 10:18:12AM +0000, daniel.lundin.mail at gmail dot c= om wrote: > --- Comment #8 from Daniel Lundin -= -- > I don't believe char past_end[0] is valid C, because it is an invalid arr= ay > declaration. Unlike [] or [*] that declares an array of incomplete type.= =20 >=20 > Since it is a function parameter, it will of course later get adjusted to= a > pointer to the first element. But it still has to be a valid declaration = to > begin with. Similarly, char arr[][] is invalid because it remains an inco= mplete > type after adjustment (see C17 6.7.6.4 =C2=A74). Agree; ISO C seems to not allow this with their wording. (I wish it did, because it's just a matter of wording, not that they don't allow passing a pointer to past the end). But maybe the wording needed for allowing this would have other undersirable consequences, so I'm happy as long as GNU C would support this. > gcc does allow [0] as an extension since that was commonly used for purpo= ses of > implementing the "struct hack" back in the days before flexible array mem= bers > were standardized. >=20 > The conclusion ought to be that gcc should let [0] through if compiled in > -std=3Dgnu23 mode but not in -std=3Dc23 and/or -pedantic. And agree; if support for this is added, pedantic or ISO C modes should complain about it. Have a lovely day! Alex=