Question about VMS C

Richard Harter g-rh at cca.CCA.COM
Tue Aug 30 16:31:50 AEST 1988


	The following came up on VMS C.  Either my understanding of
C is wrong, or the compiler is broken.  The code ran as follows:

char p[256];
...
foo () {
  ...
  int i,j, *s[128];
  ...
  for (i=0;i<128;i++) s[i] = (int *)malloc(128*sizeof(int));
  for (i=0;i<128;i++) {
    p[i] = ' ';
    p[i+128] = ' ';
    for (j=0;j<128;j++) s[i][j] = 0;
    }
  ...
  }

When this code was executed sundry things were zeroed outside of s and
the vectors pointed to by the elements of s.  When the double subscripting
was changed to *(s[i]+j) = 0 the code executed correctly.  The double
subscripting executes correctly on a host of UNIX machines and on PRIMOS.

-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.



More information about the Comp.lang.c mailing list