sandbox/bugs/array.c

qcc -g -O2 -g -Wall -pipe -D_FORTIFY_SOURCE=2 -o array/array array.c -lm
make: * [array.s] Error 1

Arrays and scalars cannot be mixed

This is because the preprocessor does not realise that the local array takes precedence over the scalar.

int main() {
  init_grid (64);
  scalar s[], p[];
  foreach()
    s[] = p[] = 1.;
  foreach() {
expected identifier or ‘(’ before ‘double’
expected ‘)’ before ‘(’ token
    double p[3]; // renaming p to something else fixes the problem
    for (int i = 0; i < 2; i++)
      p[i] = s[];
  }
}