X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Date: Fri, 08 Feb 2002 11:43:59 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-Id: <8123-Fri08Feb2002114358+0200-eliz@is.elta.co.il> X-Mailer: emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: <3C639073.4D12303@yahoo.com> (message from CBFalconer on Fri, 08 Feb 2002 08:49:31 GMT) Subject: Re: Alignment problem 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> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: CBFalconer > Newsgroups: comp.os.msdos.djgpp > Date: Fri, 08 Feb 2002 08:49:31 GMT > > Of course you can do whatever you want on a cast to int. I'm not > complaining about that. I'm just pointing out that it is > undefined behaviour as far as the language is concerned. 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. In practice, for x86 CPUs, this means that any object that is 8 bytes or larger needs to be aligned on 8-byte boundary. > On many systems, including segmented DOS, that cast would make no > sense whatsoever. I believe the purpose of the cast was to use the pointer in an arithmetic expression (bitwise AND), that's all. > So the test of the integer representation really says > nothing about the alignment, except in particular implementations. Right. But I believe the OP _was_ discussing a particular implementation: the DJGPP implementation of malloc.