From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 514023854551; Fri, 18 Nov 2022 21:28:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 514023854551 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668806888; bh=Yxh6CBgstL94boDULCEcvd684xNPnOiYdPy5EPzaxEk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OwgEPiLnb0/n47FsTlBCjiybfQjxZ2n59akn9ZgdSuVCKkI/qOaSyk1svpux6dam7 kCutnbnkiFaUyoXToPkXLRwLcvz45oUUJ984J662RtHSWWk5e5ww9sNNrgOt6GTz+6 VcQ7/oV1V7qguObTWqNMwcF4yR/TlT0NM14aSanQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107754] Confusing -Warray-bounds warning with strcpy with a null pointer Date: Fri, 18 Nov 2022 21:28:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cf_reconfirmed_on everconfirmed short_desc bug_status 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=3D107754 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-11-18 Ever confirmed|0 |1 Summary|Confusing -Warray-bounds |Confusing -Warray-bounds |warning with strcpy |warning with strcpy with a | |null pointer Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- Confirmed. Note the warning message is correct; just confusing and does not mention a null pointer here. Reduced further: struct Foo { unsigned int a; char bar[1024]; }; void setFoo(const char * value) { struct Foo * ptr =3D 0; __builtin_strcpy(ptr->bar, value); } ---- CUT --- Since the offset for the character array is non-zero, we see a non-zero constant and (based on other settings) assume it is the null pointer page a= nd we get a size of 0 (which is ok) but don't mention a null pointer. There might be other dups of this but I am not going to search for it right now.=