[previous] 3405 [next] Index[Array] is equivalent to Array[Index] but more confusing.
Declarations and definitions

It is legitimate to refer to element "n" of an array "buf" as either "buf[n] or n[buf]. Both forms mean exactly the same thing but the latter form is perverse and confusing.

For example:


/*PRQA S 2017,3120,3132,3203,3408,3625 ++*/

extern void foo(void)
{
  char array[10];
  int  i;

  for (i = 0; i < 10; i++)
  {
    array[i] = 1;               /* Conventional syntax */
    i[array] = 1;               /* Message 3405        */
  }
}

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents