------- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-02 11:31 -------
Confirmed.  Yet another SRA to bitfield magic issue.

Workaround: -fno-tree-sra.

struct A {
   short A1 ;
   short A2 ;
   int   A3 ;
};

static struct A __attribute__((noinline))
foo(int b)
{
   struct A result;
   result.A1 = (short)0;
   result.A2 = (short)0;
   /* result.A3 is intentionally not initialized */
   if (b) {
      result.A1 = (short)1;
      result.A2 = (short)2;
      result.A3 = 3;
      return result;
   }
   return result;
}

extern void abort (void);

int main()
{
  struct A myA = foo(0);
  if (myA.A1 != 0)
    abort ();
  return 0;
}


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |tree-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |4.3.0 4.3.4 4.4.0 4.4.3
      Known to work|                            |4.2.4 4.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-04-02 11:31:52
               date|                            |
            Summary|Struct to register          |[4.3/4.4 Regression] Struct
                   |optimization fails          |to register optimization
                   |                            |fails
   Target Milestone|---                         |4.3.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629

Reply via email to