From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8679 invoked by alias); 4 May 2014 12:57:07 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 8195 invoked by uid 48); 4 May 2014 12:57:01 -0000 From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug web/61054] New: Clearly note effect of memcpy optimization improvements in 4.9 changes Date: Sun, 04 May 2014 12:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: web X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: harald at gigawatt dot nl X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg00195.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61054 Bug ID: 61054 Summary: Clearly note effect of memcpy optimization improvements in 4.9 changes Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: web Assignee: unassigned at gcc dot gnu.org Reporter: harald at gigawatt dot nl Consider this reduced program: void *volatile null; volatile long zerolen; int main() { void *dst = null, *src = null; __builtin_memcpy (dst, src, zerolen); if (dst) __builtin_abort (); } This program is invalid, but until 4.8 it would compile and run without an issue. As of 4.9, it aborts. I'm not asking for GCC to change (the programs should be fixed instead), but it is not clear from the GCC 4.9 Changes page that such code no longer works. This affects real code using custom allocators and realloc-like functions, where some of those realloc-like functions don't bother to check for null pointers and assume zero-length memcpy is a no-op. When the old memory is then freed, and their free-like function performs a null pointer check, that check is optimised away if the function gets inlined. Could the GCC 4.9 Changes page get a mention of this? I do see "Better inlining of memcpy and memset that is aware of value ranges and produces shorter alignment prologues." in the IA-32/x86-64 section, but I cannot tell if it is related to that, or if it is actually arch-independent.