From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16152 invoked by alias); 7 Jul 2009 05:56:53 -0000 Received: (qmail 16100 invoked by uid 48); 7 Jul 2009 05:56:38 -0000 Date: Tue, 07 Jul 2009 05:56:00 -0000 Subject: [Bug target/40668] New: 64-bit sparc miscompiles memcpy of argument inside switch X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "blp at cs dot stanford dot edu" 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: 2009-07/txt/msg00488.txt.bz2 The following program should print 12345678. When it is built with "-O2 -m64" or "-O3 -fno-inline -m64" on sparc, it instead prints 0. I ran this test with the command "/opt/cfarm/release/4.4.0/bin/gcc -fno-inline -O3 -m64 -g combined.c" on gcc62 in the GCC compile farm. ---------------------------------------------------------------------- "/opt/cfarm/release/4.4.0/bin/gcc -v" prints: Using built-in specs. Target: sparc64-unknown-linux-gnu Configured with: ../gcc-4.4.0/configure --enable-languages=c,c++,fortran,ada --prefix=/opt/cfarm/release/4.4.0 --enable-__cxa_atexit --enable-threads=posix --disable-nls --with-mpfr=/opt/cfarm/mpfr-2.4.1 --with-gmp=/opt/cfarm/gmp-4.2.4 --with-cpu=v8 Thread model: posix gcc version 4.4.0 (GCC) ---------------------------------------------------------------------- #include #include #include /* Stores 32-bit unsigned integer X at P, which need not be aligned. */ static void put_uint32 (uint32_t x, void *p) { memcpy (p, &x, sizeof x); } void store_12345678 (int type, void *number) { switch (type) { case 1: printf ("got here\n"); put_uint32 (0x12345678, number); break; case 7: put_uint32 (0, number); break; case 8: put_uint32 (0, number); break; case 9: put_uint32 (0, number); break; } } int main (void) { uint32_t x; store_12345678 (1, &x); printf ("%x\n", (unsigned int) x); return 0; } -- Summary: 64-bit sparc miscompiles memcpy of argument inside switch Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: blp at cs dot stanford dot edu GCC build triplet: sparc64-unknown-linux-gnu GCC host triplet: sparc64-unknown-linux-gnu GCC target triplet: sparc64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40668