public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/7728: Invalid statement reordering gcc 3.2 -O2
@ 2002-10-02 13:43 rth
  0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-10-02 13:43 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, ghouston, nobody

Synopsis: Invalid statement reordering gcc 3.2 -O2

State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Wed Oct  2 13:43:24 2002
State-Changed-Why:
    Not a bug.  This code violates type aliasing rules.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7728


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

* optimization/7728: Invalid statement reordering gcc 3.2 -O2
@ 2002-08-26 12:26 ghouston
  0 siblings, 0 replies; 2+ messages in thread
From: ghouston @ 2002-08-26 12:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7728
>Category:       optimization
>Synopsis:       Invalid statement reordering gcc 3.2 -O2
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 26 11:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Gary Houston
>Release:        3.2
>Organization:
>Environment:
System: Linux x.localnet 2.4.18 #1 Sat Apr 6 12:54:37 BST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.2/configure --prefix=/usr --enable-threads=posix --enable-shared
>Description:
  Output of program below, compiled with gcc -O:
154
153
153
153
153
153
9
64

  Output when compiled with gcc -O2:
0
0
0
0
153
153
9
64

>How-To-Repeat:

#include <stdlib.h>
#include <string.h>

typedef struct
{
  unsigned long * type;
  unsigned long * pad;
  double real;
} x_double;

void * make_z (double x)
{
  void *z = malloc (50);

  memset (z, 0, 50);
  ((unsigned long *) z) [2] = 0;
  ((x_double *) z)->real = x;
  return z;
}

main ()
{
  void *z = make_z (3.2);
  double d = ((x_double *) z)->real;
  int i;

  for (i = 0; i < sizeof (double); i++)
    {
      printf ("%d\n", ((unsigned char *) &d)[i]);
    }
  return 0;
}

>Fix:
   reduce optimization
>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-10-02 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-02 13:43 optimization/7728: Invalid statement reordering gcc 3.2 -O2 rth
  -- strict thread matches above, loose matches on Subject: below --
2002-08-26 12:26 ghouston

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).