Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | pacman@kosh.dhis.org (Alan Curry) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Alignment problems |
| Date | 2011-12-01 02:57 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jb6qe2$o12$1@speranza.aioe.org> (permalink) |
| References | <jb6gbf$58a$1@speranza.aioe.org> |
In article <jb6gbf$58a$1@speranza.aioe.org>,
jacob navia <jacob@jspamsink.org> wrote:
>I am trying to test the containers library in different environments
>
>One of those is SUN sparc, that crashes when a double is accessed
>in an address not multiple of 8. I got an access to an old one:
>
>: ~/ccl ; uname -a
>SunOS 5.9 Generic_118558-25 sun4u sparc SUNW,Sun-Fire-V210
>
>Now, I have a list container with elements that
>have this structure:
>
>typedef struct _ListElement {
> struct _ListElement *Next;
> char Data[MINIMUM_ARRAY_INDEX]; // Generic storage...
>} ListElement;
>
>
>If I store double data in the "Data" member the machine will
>crash since apparently it is a 32 bit SPARC, and the start of Data
>is NOT aligned to an eight byte boundary.
It'll crash if you do the store by casting a pointer. It won't if you do it
with a memcpy, which is what you should do when you're treating a char array
as "generic storage".
It seems to me it'd be easier if the list implementation didn't know anything
about the type of the list elements except their size. Then you'd be forced
to use memcpy for all transactions.
--
Alan Curry
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Alignment problems jacob navia <jacob@spamsink.net> - 2011-12-01 01:05 +0100
Re: Alignment problems Ian Collins <ian-news@hotmail.com> - 2011-12-01 13:15 +1300
Re: Alignment problems pacman@kosh.dhis.org (Alan Curry) - 2011-12-01 02:57 +0000
Re: Alignment problems gordonb.hpln0@burditt.org (Gordon Burditt) - 2011-11-30 21:27 -0600
Re: Alignment problems jacob navia <jacob@spamsink.net> - 2011-12-01 13:38 +0100
Re: Alignment problems pacman@kosh.dhis.org (Alan Curry) - 2011-12-01 20:38 +0000
Re: Alignment problems jacob navia <jacob@spamsink.net> - 2011-12-01 21:50 +0100
Re: Alignment problems Ian Collins <ian-news@hotmail.com> - 2011-12-02 10:27 +1300
Re: Alignment problems Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-12-04 00:23 +0000
Re: Alignment problems Ian Collins <ian-news@hotmail.com> - 2011-12-04 13:31 +1300
Re: Alignment problems ImpalerCore <jadill33@gmail.com> - 2011-12-01 14:34 -0800
Re: Alignment problems "BartC" <bc@freeuk.com> - 2011-12-01 13:46 +0000
Re: Alignment problems Keith Thompson <kst-u@mib.org> - 2011-12-01 14:15 -0800
Re: Alignment problems David Thompson <dave.thompson2@verizon.net> - 2012-01-19 02:44 -0500
Re: Alignment problems "James" <no@spam.invalid> - 2011-12-01 19:43 -0800
Re: Alignment problems "Brain" <Brian@myhome.com> - 2011-12-04 02:47 -0600
Re: Alignment problems Keith Thompson <kst-u@mib.org> - 2011-12-04 08:26 -0800
Re: Alignment problems Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-12-08 00:12 +0200
Re: Alignment problems Keith Thompson <kst-u@mib.org> - 2011-12-07 22:31 -0800
Re: Alignment problems lovecreatesbeauty <lovecreatesbeauty@gmail.com> - 2011-12-08 21:43 -0800
Re: Alignment problems Keith Thompson <kst-u@mib.org> - 2011-12-09 01:31 -0800
Re: Alignment problems Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-12-09 14:15 +0200
csiph-web