From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AE9E33858C53; Fri, 2 Dec 2022 15:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE9E33858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669995505; bh=x3LbzKYpxhuayovwM6r+ubyJ4SeStFWu94ZVk0e5UK4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NnhAUDiuaElaVJjDskXWCUPiiTCjN5qEI4eRX1l0O1gljrZT/pGq8+fZxyTO2nuv1 wWG4ggy1MGdrTO5/+DTFzrw91Qvcl80t4V8Uu3BODH0yLSP07Cb75FbO1OZY1agnUU 3DY8L+oZ21lAqalkpv51hdEXd6H9fEayImpfJXBo= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107951] Invalid flexible array use not detected in nested structs by the C frontend Date: Fri, 02 Dec 2022 15:38:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D107951 qinzhao at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |qinzhao at gcc dot gnu.org --- Comment #2 from qinzhao at gcc dot gnu.org --- (In reply to Richard Biener from comment #1) > > ./cc1 -quiet t.c -pedantic-errors > t.c:7:6: error: invalid use of structure with flexible array member > [-Wpedantic] > 7 | F2 flex; > | ^~~~ >=20 > so this is supposedly a GCC extension, treating [] as [0] in this context? I found this in the gcc doc: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html#Zero-Length "A structure containing a flexible array member, or a union containing such= a structure (possibly recursively), may not be a member of a structure or an element of an array. (However, these uses are permitted by GCC as extension= s.)" Looks like this usage is permitted by GCC extensions. However, cannot find the details in the doc on how GCC treat these usage.=