From: Rob Newberry <robnewberry@grouplogic.com>
To: gcc-help@gcc.gnu.org
Subject: GCC 2.9.5, Solaris 2.8, SPARC - alignment issue - PLEASE HELP!
Date: Tue, 24 Jul 2001 14:24:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.10.10107241712190.17275-100000@host3.grouplogic.com> (raw)
Hi,
I have some legacy code, and I really, really, really need to not modify
it. This code has alignment issues, but I would expect the compiler (or
the OS maybe) to handle this for me.
Here's some example of the code that causes problems:
char key[256];
long value = 1;
// 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));
I have tried compiling with STRICT_ALIGNMENT=1 and
SLOW_UNALIGNED_ACCESS=1, but neither is helping. It always seg-faults.
Is there a solution to my problem on Sun OS 5.8 with GCC?
I am amenable to mucking with the Makefile or changing some kind of OS
configuration. The thing that I can't do is modify the code.
(Actually, I can modify the code, but the problem is that I'm not sure I
can find all the places this could happen in the code, so I'd like to
simply let the compiler do it. If there is a way to have the compiler
generate an error every time it sees misalignment, that would also be OK,
but absolutely less optimal.)
PLEASE HELP!
Rob
---------------------------------------------------------------------
Rob Newberry
Director of Fajita Technology
Group Logic, Inc.
next reply other threads:[~2001-07-24 14:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-24 14:24 Rob Newberry [this message]
2001-07-26 16:23 ` Alexandre Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.10.10107241712190.17275-100000@host3.grouplogic.com \
--to=robnewberry@grouplogic.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).