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 <stdint.h> #include <stdio.h> #include <string.h> /* 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