From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D21603858401; Thu, 7 Mar 2024 10:50:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D21603858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709808644; bh=wK+5pVEuRur+ZBI56RToZTYtUexzS/SUXR9EYsVvf5M=; h=From:To:Subject:Date:From; b=Og4U3R/Djhkl/ZSytbQcQpXimGIYRXeqj5MgVS8iwZ4EWJP78xyMJUCCjItEm3vR6 9dwGbPT+tqc+vt1FUgLupOukrGfpDk39AkgZuMnacDfcIDZZ6khP9oJVptalYTS0h5 DJdvhxsEg++cUYum9tnpHyHlrz9wmoRM2G8AeU4Y= From: "daniel.lundin.mail at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114266] New: No -pedantic diagnostic for zero-sized array in compound literals Date: Thu, 07 Mar 2024 10:50:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.lundin.mail at gmail dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114266 Bug ID: 114266 Summary: No -pedantic diagnostic for zero-sized array in compound literals Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: daniel.lundin.mail at gmail dot com Target Milestone: --- (int[]){}; produces no diagnostics with -std=3Dc23 -pedantic. Empty initalizer lists are OK under -std=3Dc23 and -std=3Dgnu so that's not= the problem. gcc correctly gives a diagnostic for that in -std=3Dc17 -pedantic = mode. Zero-sized arrays should however give a diagnostic in -std=3Dcxx -pedantic = mode. Prior to C23 this was not really a problem as we would get a diagnostic for= the empty initializer list. But now this non-conforming C compiles cleanly even with -pedantic set. A diagnostic similar to the one given in clang would be good: warning: zero size arrays are an extension [-Wzero-length-array] As I understand it, gcc did have -Wzero-length-array in the past but removed it? See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94428. The options -Wstrict-flex-arrays -fstrict-flex-arrays seem to have no effect (and my example isn't a flexible array member but a compound literal).=