[previous] 3307 [next] The operand of 'sizeof' is an expression with implied side effects, but they will not be evaluated.
Side Effects REFERENCE - ISO:C90-6.3.3.4 The sizeof Operator - Semantics

The operand of this 'sizeof' operator is an expression which would normally result in some side effects. However the operand of a sizeof operator is never evaluated. It exists only to define the type for which sizeof will return a size.

It usually makes little sense for the operand of the sizeof operator to be anything other than a type or an object identifier.

For example:


/*PRQA S 489,702,2017,2211,3198,3199,3203,3227,3408,3602,3625 ++*/

long foo(int x)
{
    long y;
    unsigned long un;

    y = x;

    un = sizeof(++y );                /* Messages 3307 and 3470 */
    un = sizeof(x + 1);               /* Message  3470 */

    return y;
}

See also:

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