From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DBAB43864877; Wed, 14 Sep 2022 05:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBAB43864877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663133894; bh=cBsXKvYXz2l0YrFk/Eqp4AmxZSgtTl31RJnHzKy0pDw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EIRjKzE3kpQTXk+9My6cisDU1ftWTgd+ph/IZGWdMnwbNDVwXKaiuBHFvd1tV0bEV mFCaJSdhGcJZlSH7PE8XAKkmaseuyZjAHF1Uuklznb07391Dxq0vxQth0GyJe2HcNx xyG0ksNFfpbC+U7huzlMGDAuTy0ZWqo4qCl9pkI4= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106939] Linker-defined symbols are stained due to 'array subscript is partly outside array bounds' warning Date: Wed, 14 Sep 2022 05:38:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: resolution 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=3D106939 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|DUPLICATE |INVALID --- Comment #3 from Andrew Pinski --- #include extern char _src[], _dst[]; // Defined by the linker int main(void) { char *l_src =3D src; char *l_dst =3D dst; asm ("" : "+r" (l_src)); asm ("" : "+r" (l_dst)); memcpy(l_src, l_dst + 1024, 1111); return 0; } --- CUT --- Well this works too because you are not comparing the start and ends: #include extern char _src[], _dst[]; // Defined by the linker int main(void) { memcpy(&_dst[0], &_src[0] + 1024, 1111); return 0; } ----- CUT --- Basically this is a C question really as _src/_dst is only size of 1 in the original code you provided while in the above two cases it is an unknown si= ze.=