From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5B023858298; Tue, 28 Nov 2023 07:20:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5B023858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701156018; bh=GwNsjNJ+9VO4LZouGhE7oSIP5SHnQi6tyHwuG9fpVGw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=laKGInRr7kVQw2tFuqdaKlopswLTMRzYvpctfYFXbD+AGB5Lyy/CxG5f1L6Z5LIQw uJh5KRXJYTXdL3ZFxRazsJwoJrzdJDaPnziB83eWmPAozDyJ+TgHB6CutW9CymXrU2 TiBmfDyTbGjX/O/j2arAZuJfIQiVMlmNzVmvN3JA= From: "post+gcc at ralfj dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32667] block copy with exact overlap is expanded as memcpy Date: Tue, 28 Nov 2023 07:20:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: post+gcc at ralfj dot de 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: 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=3D32667 --- Comment #52 from post+gcc at ralfj dot de --- For the point discussed earlier with the `restrict` in the musl memcpy, I h= ad another look at the definition of `restrict` and it's not entirely clear to= me any more that there is UB here. The restrict rules only apply to objects th= at are "also modified (by any means)". Now the question is, does "*X =3D *X" m= odify the object? Is a write always a modification or only if the stores representation changes or only if the stored value changes? If it requires a representation change, then "memcpy(x, x, n)" does not mod= ify anything, and hence there is no UB from "restrict".=