Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!maths.tcd.ie!tim From: tim@maths.tcd.ie (Timothy Murphy) Newsgroups: comp.std.c Subject: Casting pointers Summary: Can a char* always be cast as an int* Keywords: Pointers, casting Message-ID: <1990Sep29.201144.23113@maths.tcd.ie> Date: 29 Sep 90 20:11:44 GMT Organization: Dept. of Maths, Trinity College, Dublin, Ireland. Lines: 25 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