Bug 6855

Summary: An egcc optimizer bug
Product: [Retired] Red Hat Linux Reporter: ezharkov
Component: egcsAssignee: Cristian Gafton <gafton>
Status: CLOSED RAWHIDE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: ezharkov
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-02-05 18:59:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ezharkov 1999-11-09 18:16:21 UTC
The following program:

tcsh> cat bug.c
#include <stdio.h>
#include <stdlib.h>

union u {
  unsigned i;
  struct {
    unsigned low : 16;
    unsigned high : 16;
  } s;
};

static void cvt (unsigned *v) {
  union u u;
  u.i = *v;
  u.s.low = 3;
  memcpy (v, &u.i, sizeof (unsigned));
}

int main () {
  unsigned i = 0x00010002;
  cvt (&i);
  printf ("res = %08x\n", i);
  return EXIT_SUCCESS;
}

Compiled on:

tcsh> uname -a
Linux hostname 2.2.12 #3 SMP Thu Sep 2 03:34:03 MDT 1999
i586 unknown

Using cc:

tcsh> cc --version
egcs-2.91.66

With the command:

tcsh> cc -O1 -o bug bug.c

Produces the following result:

tcsh> ./bug
res = 00000003

I would prefer it to produce a "00010003" result.

Comment 1 Jim Kingdon 1999-11-09 21:52:59 UTC
At first glance this looks like the same bug as 5184 (also see
http://people.redhat.com/kingdon/), which for reference concerns
the "addressof" feature within GCC.

Comment 2 Bill Nottingham 2000-02-05 18:59:59 UTC
Fixed in the egcs currently in Raw Hide.