From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 229503858C36; Wed, 28 Jun 2023 15:09:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 229503858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687964950; bh=ayGK9HNLEpCSXK9nyhlYf9sncjIij6BCaEyx0O9M9ro=; h=From:To:Subject:Date:From; b=qa0Xpb5rrExfTqAdRfmWSrohTp+Vq304EAdpbMYrFsJaOsRLx2XOOn21xGLfjFlpA eSprr0OqCWNOnVnPgh7g4BgjKxUnN9sHxhV2BaaKgIxcwQ7cNGsGQryVPAezIvCkYK lyPiaVh4RT5Y6YQjYylyO71WlRdLW9iabaL+r6N8= From: "sirl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110458] New: -Warray-bounds=2 new false positive Date: Wed, 28 Jun 2023 15:09:09 +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: sirl 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 attachments.created 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=3D110458 Bug ID: 110458 Summary: -Warray-bounds=3D2 new false positive Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- Created attachment 55412 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55412&action=3Dedit testcase Since somewhere between r14-1870 and r14-2097 a new -Warray-bounds=3D2 false positive is shown for this little testcase: typedef struct { unsigned arr1[4]; unsigned arr2[4]; } data; void f_notok(void *arrayOut) { int i; unsigned *arr2; unsigned *arr1; data *dataOut; dataOut =3D (data *)arrayOut; arr1 =3D dataOut[0].arr1; arr2 =3D dataOut[0].arr2; i =3D 0; for (; i < 4; i++) { arr1[i] =3D 0; arr2[i] =3D 0; } } When compiled with trunk@r2097 "gcc -O2 -W -Wall -Warray-bounds=3D2 -c bug-Warray-bounds-eq-2.c" the warning is: bug-Warray-bounds-eq-2.c: In function 'f_notok': bug-Warray-bounds-eq-2.c:16:13: warning: '__builtin_memset' offset [16, 31] from the object at 'arrayOut' is out of the bounds of referenced subobject 'arr1' with type 'unsigned int[4]' at offset 0 [-Warray-bounds=3D] 16 | arr1[i] =3D 0; | ~~~~~~~~^~~ bug-Warray-bounds-eq-2.c:2:12: note: subobject 'arr1' declared here 2 | unsigned arr1[4]; | ^~~~ gcc-13.1.1 and earlier didn't warn here. The attached full testcase also sh= ows that slight variations in the code silence the warning.=