This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Structure Alignment Bug in Sparc.
- From: "Nitin Gupta" <ngupta at GlobespanVirata dot com>
- To: <gcc-bug at gcc dot gnu dot org>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Mon, 18 Aug 2003 21:16:59 +0530
- Subject: Structure Alignment Bug in Sparc.
Hi,
A structure assignment statement of a struct
containing a 8 byte member causes a ldd assembly
instruction to be generated. -mno-fastest-structs
doesn't help either.
I have seen this happening for Sparclet, it seems
this would reproduce for other sparc ports also.
I'm using GCC 3.2 released, with -O3 flag. The bug
does not reproduce without optimization.
Test program
struct _st2 {
int * a;
int c;
int * b;
int d;
};
typedef struct _st2 _st2;
typedef _st2 st2;
typedef struct st1{
st2 a;
int l;
long long b;
}st1;
extern void print(st2 v);
void func_test(st1 * var)
{
st2 v = var->a;
print(v);
}
Assembly
_func_test:
!#PROLOGUE# 0
save %sp, -136, %sp
!#PROLOGUE# 1
ldd [%i0+8], %o4 <--- This should have
ldd [%i0], %o2 <--- been 4 ld
add %fp, -40, %o0
std %o4, [%fp-32]
std %o2, [%fp-40]
std %o2, [%fp-24]
call _print, 0
...
...
Please let me know if I'm missing something
obvious.
Thanks and Regards,
Nitin