SIGBUS on Solaris 10 Sparc
Hi all,
I have met a strange problem while I use GCC to compile a very simple
src:
int main()
{
short p[10];
int *pp = (int*)&p[1];
*pp = 1;
return 1;
}
Whe the src is compiled with GCC gcc (GCC) 3.4.3
(csl-sol210-3_4-branch+sol_rpath) and3.3.2
), it will generate core dump for SIGBUS.
I know this is due to unaligned memory access for SPARC.
So I add the type attribute for the short array;
short p[10] __attribute__ ((aligned (4)));
But it doesn't take effect for the memory alignment and still generates
a coredump.
The compile command is also very simple: /usr/sfw/bin/gcc align.c
Does anybody know how to make this piece of code execute sucessfully
with changing src.
Your solution and comments are highly appreciated.

