[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    Re: egcs 1.1.x union/aliasing bug (PPC)
From:       Jeffrey A Law <law () upchuck ! cygnus ! com>
Date:       1999-05-31 6:46:50
[Download RAW message or body]


  In message <199905191704.KAA11360@scv4.apple.com>you write:
  > Hey there,
  > 
  > There appears to be a problem with aliasing using egcs-1.1.1 PowerPC
  > on an AIX box and egcs-1.1.2 on a MacOS X box.
  > 
  > Compiling the following snippet with egcs-1.1.x -O2
  > 
  >    unsigned long bad(int reg, unsigned long inWord)
  >    {
  >        union {
  >            unsigned long word;
  >            unsigned char byte[4];
  >        } data;
  > 
  >        data.word = inWord;
  >        data.byte[reg] = 0;
  > 
  >        return data.word;
  >    }
  > 
  > gives us:
  > 
  >    stw  r4, -8(r1)    <--- data.word = inWord
  >    addi r9, r1, -8    <--- create pointer to data
  >    li   r0, 0
  >    stbx r0, r9, r3    <--- data.byte[reg] = 0
  >    mr   r3, r4        <--- Oh dear.  Should be "lwz  r3, -8(r1)"
  >    blr
Thanks.  I've fixed this bug and added a test to the regression testsuite.

jeff

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic