Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!ames!sgi!shinobu!odin!sgi.com!scotth From: scotth@corp.sgi.com (Scott Henry) Newsgroups: comp.sys.sgi Subject: Re: Character pointer c core dump Message-ID: Date: 12 Apr 90 08:20:17 GMT References: <5051930@ub.cc.umich.edu> Sender: news@odin.corp.sgi.com Reply-To: scotth@sgi.com (Scott Henry) Organization: Silicon Graphics Inc, Mountain View, CA Lines: 46 In-reply-to: Mary_Kay_Anderson@UB.CC.UMICH.EDU's message of 12 Apr 90 04:07:24 GMT > What's wrong with this picture, or what's wrong with this > cc compiler? The following dumps core at *lp=5: > > char buf[1024]; > main() > > { > > long *lp; > > int i; > > > lp = (long *)&buf[6]; > > *lp = 5; > > printf("%ld\n", *lp); > > >} > > However.... If you replace the &buf[6] with &buf[0], it > works the way you would expect and prints 5 to the screen. > Looks like a bug? > Thanks for any help you can give me. This code came from and works on a VAX, right :-)? The MIPS processor can only access long data on long boundaries. Assuming that the buffer starts at a longword boundary, offsets that are on a longword boundary ([0], [4], [8], etc) will work, any other offset will cause a segv and core dump. If lp where a short, then offsets that are a multiple of a short (0, 2, 4, 6, etc) would work. (VAX's can access any sized data at any offset). Hope this helps! > Tim Buxton > OptiMetrics, Inc. > Tim_Buxton@um.cc.umich.edu -- Scott Henry | Traveller on Dragon Wings Information Services, | Silicon Graphics, Inc | These are my Opinions only! Whose else?