Xref: utzoo comp.sys.mac.programmer:5316 comp.sys.mac:29406 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer,comp.sys.mac Subject: Re: LSC3.0 brain damage Keywords: stdio, pointers Message-ID: <28652@ucbvax.BERKELEY.EDU> Date: 2 Apr 89 07:32:01 GMT References: <1704@ncar.ucar.edu> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Distribution: usa Organization: School of Education, UC-Berkeley Lines: 36 In article <1704@ncar.ucar.edu> bill@hao.ucar.edu (Bill Roberts) writes: >#include >#include >#include >#include >main() { > char *ptr; > int max= 400; > > ptr= (char *)malloc(500); > while (max--) > fprintf (stderr,"ptr= %d\n", ptr++); > >} This is _not_ legal C. The correct program follows: #include #include main() { char *ptr; int max= 400; ptr= (char *)malloc(500); while (max--){ fprintf (stderr,"ptr= %d\n", (int) ptr); ptr++; } } The Think C manual clearly says that int == short. The Sun compiler has int == long. Both are legal choices for compiler authors to make. In printf, %d prints an int. In Lightspeed C, it only sees the high word of the pointer, so you see no change. Lightspeed C isn't wrong, Sun isn't wrong, the original program is.