From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3872A3858C2D; Fri, 6 Jan 2023 18:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3872A3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673030906; bh=3qnRjStvgf1cuZGuijwaHazly0+IZ0HY5epfXx3+Bf4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EcZza/IufrMT59YWYKTez5gr43PEk7MnS0tmJIeEXQ7SoSu6Lpd/maICS3SId+Jxs xQOkVzveMF4HjXZPWxsb9z40aJhZWdkTLD31lHJaMWchyGagPVYXLNwwH3PwaxYciT RuOtvM0tpnHHd/h9OlpXDo6iqzGBqYqB03T9IX3U= From: "lopresti at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32667] block copy with exact overlap is expanded as memcpy Date: Fri, 06 Jan 2023 18:48:22 +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: lopresti at gmail dot com 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 #22 from Patrick J. LoPresti --- I disagree that bug 108296 is a duplicate. That bug requires code that, at least arguably, invokes undefined behavior. See e.g. https://stackoverflow.com/q/7292862/ and https://stackoverflow.com/q/610708= 28/. This bug is about clearly valid C++ code (object self-assignment) for which= GCC emits clearly invalid calls to memcpy() (with dest =3D=3D src). Now, I suspect what Andrew is thinking is that both of these bugs could be resolved by invoking memmove() instead of memcpy(). That seems like a reasonable idea to me, since small assignments get inlined and large assignments can amortize the overhead. But this bug could also be resolved in other ways, a few of which have been suggested in these comments.=