Article View: comp.lang.c.moderated
Article #2611pointer casting
From: Michal Szymanski
Date: Wed, 17 Apr 1996 15:45
Date: Wed, 17 Apr 1996 15:45
28 lines
1835 bytes
1835 bytes
There is a discussion of (void *) and pointer casting going on this list. K&R "Ansi C" book says that conversion: (type *) -> (void *) -> (type *) is guaranteed to yield the same pointer. This (and the discussion on the list) suggests that another chain: (void *) -> (type *) -> (void *) might result in some change of the original pointer. In other words I would guess that casting a void pointer to a pointer to a type requiring special memory allignment might involve adjusting it to a proper value. Is this true? I played with such conversions on Sun Sparcstation (which surely requires proper allignment of data with sizeof > 1), using both Sun compiler v. 2.0.1 and Gnu 2.6.3, but never observed such an automatic adjustment? Odd pointers casted to (e.g.) double result in Bus Error when referenced. And they show the same odd value when printed as long values. So I wonder whether this adjustment is just (nowhere-implemented) possibility or some real thing? regards, Michal. **************************************************************************** Michal Szymanski Internet: msz@sirius.astrouw.edu.pl Warsaw University Observatory Bitnet: msz@plwauw61.bitnet Al. Ujazdowskie 4 Voice: 48-22-6294011 ext 23 00-478 Warszawa, POLAND FAX: 48-22-6294967 ****************************************************************************
Technical Details
Message-ID:
<4l33mf$7pr@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: msz@sirius.astrouw.edu.pl (Michal Szymanski) Newsgroups: comp.lang.c.moderated Subject: pointer casting Date: 17 Apr 1996 10:45:19 -0500 Organization: Warsaw University Astronomical Observatory Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4l33mf$7pr@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com