delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/08/08:00:08

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Alignment problem
Date: 8 Feb 2002 12:49:58 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 22
Message-ID: <a40hhm$o19$1@nets3.rz.RWTH-Aachen.DE>
References: <3C629769 DOT AEAFB611 AT cyberoptics DOT com> <3C62A89A DOT 9DF630C5 AT yahoo DOT com> <3C630FB1 DOT E69F87A AT cyberoptics DOT com> <3C63319A DOT 2E193983 AT yahoo DOT com> <7484-Fri08Feb2002094855+0200-eliz AT is DOT elta DOT co DOT il> <3C639073 DOT 4D12303 AT yahoo DOT com> <8123-Fri08Feb2002114358+0200-eliz AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1013172598 24617 137.226.32.75 (8 Feb 2002 12:49:58 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 8 Feb 2002 12:49:58 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> The language standard (at least C99) does require malloc to return a
> pointer that is suitably aligned for the types of object for which the
> pointer could be used.  

Even byte alignment only would be "suitably aligned" in x86 world.
Sure, there's a performance hit if you have unaligned objects, but
that's not what the standard referst to when it says "suitable",
AFAIK.  That just means the CPU must accept the pointer as a pointer
to arbitrary types without crashing the program.  

> In practice, for x86 CPUs, this means that any object that is 8
> bytes or larger needs to be aligned on 8-byte boundary.

It doesn't exactly "need" to be.  It certainly should, if possible.
But that's a quality of implementation issue, not one of fulfilling
Standard requirements.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019