From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8BAEA3858D28; Fri, 2 Dec 2022 13:28:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BAEA3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669987695; bh=gS0CGd162AJ2ItIdV28boqp3jeZUPYZDXaeI2S/ZnqQ=; h=From:To:Subject:Date:From; b=uQKKLyeMnSTaQJIUn6ne74bVsDYhFnFtkhsxbtYk0koXNWMuwYf21cdEkG//8yOvC 08W36ISfvYgxRjBcGz/o4kL1D5Fk6wkcncHSjxa86okvjG1ONZQRZvsOWHlq4/T+zf E6mbwM13LjuWOmtNr7fEvEQO/xS1sI8zRFPVP+v4= From: "siddhesh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107951] New: Invalid flexible array use not detected in nested structs by the C frontend Date: Fri, 02 Dec 2022 13:28:15 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: siddhesh 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: 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=3D107951 Bug ID: 107951 Summary: Invalid flexible array use not detected in nested structs by the C frontend Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: siddhesh at gcc dot gnu.org Target Milestone: --- The following program: typedef struct { char pad; char data[]; } F2; typedef struct { F2 flex; unsigned pad; } S2; #define NULL (void *) 0 __SIZE_TYPE__ nested_flexarray (__SIZE_TYPE__ n) { S2 *p =3D __builtin_malloc (n); return __builtin_dynamic_object_size (p->flex.data, 1); } ends up treating data[] as a zero sized array in C instead of flagging an error. This is correctly handled in the C++ driver.=