This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/20102] New: Incorrect floating point code generated when assigning to "packed" structure


gcc generates incorrect code when assigning to stack residing struct 
bearing "packed" attribute. Correct code is generated when assigning to global 
struct of the same type.
Example:
//-----
typedef struct
{
  char x1;
  char x2;
  char x3;
  float v1;
  float v2;
  float v3;
  char x4;
  char x5;
} __attribute__((packed,aligned(1))) ptype1;

ptype1 g;

void foo()
{
//....
 ptype1 p;
//....
 p.v1=g.v1;
 p.v2=p.v3;
//....
}
//-----
When compiled with:
powerpc-eabi-gcc -std=gnu99 -mcpu=505 -fsingle-precision-constant -mmultiple -
mstring -fno-common -ffast-math -O3 -g3 -memb -msdata=eabi -G 26624
the following incorrect code is generated:
//---
lfs   f3, -31984(r13)  //g.v1
lfs   f2, 395(r1)      //p.v3 - incorrect misaligned load (throws exception)
stfs  f3, 387(r1)      //p.v1 - incorrect misaligned store (throws exception)
stfs  f2, 391(r1)      //p.v2 - incorrect misaligned store (throws exception)
//---
Desired behavior: at least error message; at most - consistent, byte by byte 
load/store.

-- 
           Summary: Incorrect floating point code generated when assigning
                    to "packed" structure
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oakad at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: powerpc-eabi-*


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]