From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2663 invoked by alias); 20 Feb 2008 02:02:04 -0000 Received: (qmail 2493 invoked by uid 48); 20 Feb 2008 02:01:14 -0000 Date: Wed, 20 Feb 2008 02:02:00 -0000 Subject: [Bug target/35258] New: two memcpy calls merged incorrectly with -O1 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "janis at gcc dot gnu dot org" 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 X-SW-Source: 2008-02/txt/msg02093.txt.bz2 Someone at IBM working on a very large project on s390 showed me some odd code in which two memcpy calls get merged into something that instead spreads one character into the final destination. A modification of that code that looks more normal is: char string2[9] = "1234"; void foo (void) { char temp[4]; char *p = &string2[2]; memcpy (&temp, &string2[1], 4); memcpy (p, &temp, 4); string2[1] = '.'; } The result in string2 should be "1.234" but is "1.2222" (or so says the person who reported this to me). I'll attach the full test case with both versions of the code. Based on my examination of the generated s390 code, which I had never seen before and just barely understand, this was broken in 3.0 through 3.4, OK in 4.0 through 4.2, and is broken again in 4.3. -- Summary: two memcpy calls merged incorrectly with -O1 Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: janis at gcc dot gnu dot org GCC target triplet: s390-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35258