public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/40668]  New: 64-bit sparc miscompiles memcpy of argument inside switch
@ 2009-07-07  5:56 blp at cs dot stanford dot edu
  2009-07-07  5:58 ` [Bug target/40668] " blp at cs dot stanford dot edu
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: blp at cs dot stanford dot edu @ 2009-07-07  5:56 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-09-20 21:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-07  5:56 [Bug target/40668] New: 64-bit sparc miscompiles memcpy of argument inside switch blp at cs dot stanford dot edu
2009-07-07  5:58 ` [Bug target/40668] " blp at cs dot stanford dot edu
2009-07-07  5:58 ` blp at cs dot stanford dot edu
2009-07-07 11:36 ` mikpe at it dot uu dot se
2009-07-07 16:28 ` mikpe at it dot uu dot se
2009-07-07 19:05 ` jakub at gcc dot gnu dot org
2009-07-07 23:10 ` mikpe at it dot uu dot se
2009-07-08 16:43 ` mikpe at it dot uu dot se
2009-07-08 17:30 ` blp at cs dot stanford dot edu
2009-07-11  9:24 ` jakub at gcc dot gnu dot org
2009-07-11  9:26 ` jakub at gcc dot gnu dot org
2010-09-20 21:46 ` ebotcazou at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).