This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC 2.9.5, Solaris 2.8, SPARC - alignment issue - PLEASE HELP!
- To: Rob Newberry <robnewberry at grouplogic dot com>
- Subject: Re: GCC 2.9.5, Solaris 2.8, SPARC - alignment issue - PLEASE HELP!
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 26 Jul 2001 20:23:04 -0300
- Cc: gcc-help at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <Pine.LNX.4.10.10107241712190.17275-100000@host3.grouplogic.com>
On Jul 24, 2001, Rob Newberry <robnewberry@grouplogic.com> wrote:
> char key[256];
> // this causes a SIGSEGV on SPARC
> *((long*)&key[2]) = value;
> I know this is cruddy, but I would _EXPECT_ the compiler to essentially
> catch this and (more-or-less) rewrite it as something similar to:
> memcpy( &key[2], &value, sizeof(long));
Except that, when you tell it it's accessing a long, it's free to
assume it can do it efficiently, without using the byte access
instructions. If you mean to do byte-per-byte access, use memcpy
explicitly.
> Is there a solution to my problem on Sun OS 5.8 with GCC?
It might be possible to use signal handlers to trap bus errors and
adjust unaligned accesses.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me