Character pointer c core dump

Mary_Kay_Anderson at UB.CC.UMICH.EDU Mary_Kay_Anderson at UB.CC.UMICH.EDU
Thu Apr 12 14:07:24 AEST 1990


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.
 
                             Tim Buxton
                             OptiMetrics, Inc.
                             Tim_Buxton at um.cc.umich.edu
 



More information about the Comp.sys.sgi mailing list