From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B37BF385840A; Wed, 11 Oct 2023 19:39:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B37BF385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697053174; bh=4k8LZprfpZXi1g6YxBsfPt3ieWAKFAaYXpbMnqGw9X8=; h=From:To:Subject:Date:From; b=wy+qpZ7IWJ4dUNO1a4OP8jKCyNRt9r4Ls8ZXTR4fBZvg+f7BY1yzRSgf8SAHoU2JS 801ehd23k+DXhrP7DedttkK0ftKYSCKG5ZnwqD3DYdLVFrtRfObq39asPxqI2J9yOE 81nakBaTU8z2NABANai2pWGOm0jsNl5hOsoaTtUo= From: "crrodriguez at opensuse dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111775] New: -Wstrict-flex-arrays missing diagnostics with unions Date: Wed, 11 Oct 2023 19:39:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crrodriguez at opensuse dot 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=3D111775 Bug ID: 111775 Summary: -Wstrict-flex-arrays missing diagnostics with unions Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crrodriguez at opensuse dot org Target Milestone: --- following code is not diagnosed #include #include #include struct foo { int dum; union { /* or [1] */ char a[0]; wchar_t b[0]; } fn; }; int main(void) { struct foo *f =3D malloc(sizeof(*f)); /* or really any use of the union does not matter */ printf("%p", f->fn.b); free(f); return 0; } compile options -Wall -fstrict-flex-arrays -Werror=3Dstrict-flex-arrays -O2 This test is a silly mockup of real widespread code, which goes undiagnosed until test suites run and/or is built with ubsan.=