Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!modcomp!joe From: joe@modcomp.UUCP Newsgroups: comp.lang.c Subject: Re: foo = *((bar *)stuff) Message-ID: <90700002@modcomp> Date: 2 May 89 17:52:00 GMT References: <712@tekno.chalmers.se> Lines: 22 Nf-ID: #R:tekno.chalmers.se:712:modcomp:90700002:000:855 Nf-From: modcomp.UUCP!joe May 2 13:52:00 1989 yair@tybalt.caltech.edu writes: >Sven (Sciz) Axelsson writes: >>Isn't this code supposed to assign the integer value contained >>at memory position 10 to the variable x? >> >> x = *((int *)10); >> >(int *) 10 should convert the integer 10 to a pointer, then the * >should dereference the pointer, which on most (*not* all) machines >should read location 10 of memory. Note that this is extremely >nonportable and very machine (even compiler) dependent. [...] On 80x86 >machines this can cause problems since 'far' pointers may be different >from 'near' pointers, ... One (word-oriented) machine I've worked on had pointers of different types with different internal representations. A (char *)10 would reference the 10'th *byte* of memory and a (int *)10 the 10'th *word* of memory. Clearly, a very nonportable construct! joe korty uunet!modcomp!joe