[chbot] !!!!!!!! Choc fish challenge 2 !!!!!!!!!

hamster hamster at snap.net.nz
Wed Aug 3 00:01:27 BST 2011


Indexing an ordinal by a pointer is the work of the devil. 

I couldn't believe that a C complier would actually compile this without
error, so I tried it (after all challenge is over). It compiles clean
without errors:

  [tmp]$ cat test.c
  int main( int c, char *v[])
  {
    while(c[v] == v[c])
    {
     c++; v++;
    }
    return 0;
  }
  [tmp]$ gcc -o test test.c  -Wall -pedantic
  [tmp]$ ./test

With optimisations on, and looking at the assembler - yeap, an infinite
loop doing nothing.

  [tmp]$ gcc -S -c  test.c  -Wall -pedantic -O4
  [tmp]$ cat test.s
  ....
  main:
  .L3:
        jmp     .L3
  ....


Mike







More information about the Chchrobotics mailing list