Article View: comp.lang.c.moderated
Article #2561Re: void* type
From: news
Date: Tue, 09 Apr 1996 03:50
Date: Tue, 09 Apr 1996 03:50
22 lines
1538 bytes
1538 bytes
fred@genesis.demon.co.uk writes: >In article <4k1q3p$5bj@solutions.solon.com> news@Thinkage.On.CA writes: >>to a double *. Since malloc guarantees alignment (actually, only *after* >>casting, but only a very malicious malloc would do that to you), this can >>safely be done. > >The standard actually says 7.10.3: > >"The pointer returned if the allocation succeeds is suitably aligned so that > it may be assigned to a pointer to any type of object..." > >So the alignment is guaranteed for the pointer returned i.e. prior to >conversion. No, it only says that you can do the assignment, i.e., it won't cause a trap or somesuch. The assignment itself might change the pointer value. After the assignment eveything must be as we all expect. Imagine a malloc that returns a pointer to a non-aligned byte, and the casting works by rounding forward to the next alignment boundary. -- David Tanguay dat@Thinkage.on.ca http://www.thinkage.on.ca/~dat/ Thinkage, Ltd. Kitchener, Ontario, Canada [43.24N 80.29W]
Technical Details
Message-ID:
<4kcmqc$p5f@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4jv7ge$d49@solutions.solon.com> <4k1q3p$5bj@solutions.solon.com> <4k619q$aq4@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: news@Thinkage.On.CA Newsgroups: comp.lang.c.moderated Subject: Re: void* type Date: 8 Apr 1996 22:50:36 -0500 Organization: Thinkage Ltd., Kitchener, Ontario Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4kcmqc$p5f@solutions.solon.com> References: <4jv7ge$d49@solutions.solon.com> <4k1q3p$5bj@solutions.solon.com> <4k619q$aq4@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com