Path: utzoo!attcan!uunet!mcsun!unido!pbinfo!fillg1 From: fillg1@uni-paderborn.de (Michael Illgner) Newsgroups: comp.std.c Subject: Re: Casting pointers Keywords: Pointers, casting Message-ID: <1990Oct2.123350.20527@uni-paderborn.de> Date: 2 Oct 90 12:33:50 GMT References: <1990Sep29.201144.23113@maths.tcd.ie> Organization: Uni-GH Paderborn, West Germany Lines: 39 in tim@maths.tcd.ie (Timothy Murphy) writes: >I recently came across the following problem, >when temporarily 'borrowing' od from Unix to Mac. >Consider a program like this. >#include >char *buf = "abc"; >main() >{ > int *n = (int*) buf; > printf("%d", *n); >} >Should this always work? >On the Mac, with THINK C, >it only works if buf has an even address. >Otherwise it bombs out. >Is that a bug, according to standard C? >-- >Timothy Murphy >e-mail: tim@maths.tcd.ie I think it is a problem with the Macs 680X0 processor. Larger objects like integer number are aligned at even addresses, and if they are accessed at an odd address, the processor raises an exception. |-----------------------------------------------------------------------------| |It`s not dead, | Michael Illgner | email to | |It justs smells funny ! | Theodorstr. 27 | | | | 4790 Paderborn (Germany) | fillg1@uni-paderborn.de | |Life, Universe and all | 05251/26488 or 60-2331 | | ------------------------------------------------------------------------------|