From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 530A13858031; Mon, 18 Dec 2023 21:32:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 530A13858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702935151; bh=9C4fJiPrs630s0IGN7QznUDAfN8yqYFf9oXCUXQcvdk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L9h1GfKf2P86txxBzVujDQJex1DklrrxiOk/xQaSOHpNi/VfQEu3yHlQxDr0lARjC oeCJa1dEKgdMRvHCLFMCoeh+Q8kH6eWYOT1IDZkaxIOY3XVhwuU22qeQ3nzqCTTXff 4m8dom9V+l/yLK8QkmaCjCDY+VZwkjfuRuR3uUIk= From: "david at westcontrol dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/56888] memcpy implementation optimized as a call to memcpy Date: Mon, 18 Dec 2023 21:32:30 +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.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david at westcontrol dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth 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=3D56888 --- Comment #47 from David Brown --- (In reply to M Welinder from comment #46) > Should "-std=3Dc99" imply turning off these optimizations? >=20 > Creating calls to, say, strlen is incompatible with the C99 standard and > perhaps better limited to "-std=3Dgnu-something" or an opt-in f-flag. How is it incompatible with C99 to create calls to library functions? I can think of a two possibilities: 1. If the function implementation plays with errno (allowed in 7.5p3), in a= way that is visible to the code. 2. If the function is called with parameters that may invoke undefined behaviour (such as calling "strlen" without being sure that the parameter points to a null-terminated string), where such undefined behaviour is not already present. If the user writes code that acts like a call to strlen (let's assume the implementation knows strlen does not change errno), then the compiler can replace it with a library call. Similarly, if the user writes a call to strlen, then the compiler can replace it with inline code. As long as there is no difference in the observable behaviour, the transformation is allowed. Or am I missing something here?=