[previous] 0945 [next] [C99] WARNING. Operand of sizeof is an expression of variable length array type.
ISO C99 Language features REFERENCE - ISO:C99-6.5.3.4 The sizeof operator - Semantics

The sizeof operator has been applied to an operand of 'variable length array' type. QA·C does not support the full semantic implications associated with this syntax and therefore analysis may have some unexpected results. Message 0945 is generated in order to warn about this limitation.

The result of the sizeof operator is normally a constant value (known at compile time). If the operand happens to be an expression, the expression is not evaluated.

In the special situation where the operand to sizeof is of variable length array type, there are 2 consequences:
  1. The result of the operation is no longer constant and can only be computed at run-time.
  2. The expression determining the size of the array is evaluated and in the process may generate side-effects.

For example:


/*PRQA S 702,1051,2017,2211,3196,3199,3203,3227,3408 ++*/

extern void foo(int n)
{
    int buf[n];
    unsigned long s;

    s = sizeof(buf);                    /* Message 0945 */
}

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