public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: ghouston@arglist.com
To: gcc-gnats@gcc.gnu.org
Subject: optimization/7728: Invalid statement reordering gcc 3.2 -O2
Date: Mon, 26 Aug 2002 12:26:00 -0000	[thread overview]
Message-ID: <20020826182028.3210.qmail@arglist.com> (raw)


>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:


             reply	other threads:[~2002-08-26 18:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-26 12:26 ghouston [this message]
2002-10-02 13:43 rth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020826182028.3210.qmail@arglist.com \
    --to=ghouston@arglist.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).