Debian Bug report logs - #488563
[powerpc] Optimisation results in wrong code

version graph

Package: gcc-4.3; Maintainer for gcc-4.3 is Debian GCC Maintainers <debian-gcc@lists.debian.org>;

Reported by: Sjoerd Simons <sjoerd@debian.org>

Date: Sun, 29 Jun 2008 19:33:01 UTC

Severity: serious

Found in version gcc-4.3/4.3.1-2

Done: Bastian Blank <waldi@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#488563; Package gcc-4.3. Full text and rfc822 format available.

Acknowledgement sent to Sjoerd Simons <sjoerd@debian.org>:
New Bug report received and forwarded. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Sjoerd Simons <sjoerd@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: [powerpc] Optimisation results in wrong code
Date: Sun, 29 Jun 2008 20:19:05 +0100
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 sent to Bastian Blank <waldi@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Sjoerd Simons <sjoerd@debian.org>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #10 received at 488563-done@bugs.debian.org (full text, mbox):

From: Bastian Blank <waldi@debian.org>
To: 488563-done@bugs.debian.org
Subject: Re: Bug#488563: [powerpc] Optimisation results in wrong code
Date: Sun, 29 Jun 2008 22:25:56 +0200
On Sun, Jun 29, 2008 at 08:19:05PM +0100, Sjoerd Simons wrote:
>   *((uint64_t *) h) = (uint64_t) 0;
>   *((uint32_t *) h) = (uint32_t) 0xffffffff;

Violation of aliasing rules. h points either to a uint32_t oder uint64_t
not both.

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

-fstrict-aliasing enables standard conforming aliasing handling.

> This error causes the gstreamer testsuite to break on powerpc.

You break the rules, gcc breaks your output. No bug.

Bastian

-- 
Yes, it is written.  Good shall always destroy evil.
		-- Sirah the Yang, "The Omega Glory", stardate unknown




Information forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#488563; Package gcc-4.3. Full text and rfc822 format available.

Acknowledgement sent to Sebastian Dröge <slomo@circular-chaos.org>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. Full text and rfc822 format available.

Message #15 received at 488563@bugs.debian.org (full text, mbox):

From: Sebastian Dröge <slomo@circular-chaos.org>
To: 488563@bugs.debian.org
Cc: Bastian Blank <waldi@debian.org>
Subject: Re: Bug#488563: [powerpc] Optimisation results in wrong code
Date: Mon, 30 Jun 2008 11:39:43 +0200
[Message part 1 (text/plain, inline)]
> On Sun, Jun 29, 2008 at 08:19:05PM +0100, Sjoerd Simons wrote:
> >   *((uint64_t *) h) = (uint64_t) 0;
> >   *((uint32_t *) h) = (uint32_t) 0xffffffff;
> 
> Violation of aliasing rules. h points either to a uint32_t oder uint64_t
> not both.
> 
> > With -fschedule-insns -fstrict-aliasing:
> > $ /usr/bin/gcc-4.3  -Wall  /tmp/test.c -o /tmp/test -fschedule-insns -fstrict-aliasing
> > $ /tmp/test
> > 0
> 
> -fstrict-aliasing enables standard conforming aliasing handling.
> 
> > This error causes the gstreamer testsuite to break on powerpc.
> 
> You break the rules, gcc breaks your output. No bug.

But shouldn't gcc warn about this then? It already warns about breaking aliasing
rules in many other situations.
[signature.asc (application/pgp-signature, inline)]

Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 29 Jul 2008 07:36:17 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Mon Apr 21 10:46:27 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.