[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#488563: [powerpc] Optimisation results in wrong code



Package: gcc-4.3
Version: 4.3.1-2
Severity: serious

When using the following (somewhat contrived code):
------
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

void
misc (uint8_t **header)
{
  uint8_t *h;

  h = malloc(8);

  *((uint64_t *) h) = (uint64_t) 0;
  *((uint32_t *) h) = (uint32_t) 0xffffffff;

  *header = h;
}

int
main(int argc, char **argv)
{
  uint8_t *h;

  misc (&h);

  printf ("%x\n", *((uint32_t *)h));

  return 0;
}
-------

The result should clearly be ffffffff. Without optimisations:
$ /usr/bin/gcc-4.3  -Wall  /tmp/test.c -o /tmp/test -fschedule-insns; /tmp/test
ffffffff

With -fschedule-insns -fstrict-aliasing:
$ /usr/bin/gcc-4.3  -Wall  /tmp/test.c -o /tmp/test -fschedule-insns -fstrict-aliasing
$ /tmp/test
0

This error causes the gstreamer testsuite to break on powerpc.

  Sjoerd
-- System Information:
Debian Release: lenny/sid
  APT prefers oldstable
  APT policy: (500, 'oldstable'), (500, 'unstable'), (500, 'testing'), (101, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.25-2-powerpc
Locale: LANG=C, LC_CTYPE=nl_NL (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.3 depends on:
ii  binutils            2.18.1~cvs20080103-7 The GNU assembler, linker and bina
ii  cpp-4.3             4.3.1-2              The GNU C preprocessor
ii  gcc-4.3-base        4.3.1-2              The GNU Compiler Collection (base 
ii  libc6               2.7-12               GNU C Library: Shared libraries
ii  libgcc1             1:4.3.1-2            GCC support library
ii  libgomp1            4.3.1-2              GCC OpenMP (GOMP) support library

Versions of packages gcc-4.3 recommends:
ii  libc6-dev                     2.7-12     GNU C Library: Development Librari

-- no debconf information



Reply to: