[previous] 0536 [next] [C] First operand of '&&', '||' or '?' must have scalar (arithmetic or pointer) type.
Constraint violations REFERENCE - ISO:C90-6.3.13-15 Logical AND Operator - Constraints

This is a constraint error

The first operand of the &&, || and ? operators must be of scalar type. Operands of void, struct, union or array type are not permitted.

For example:


/*PRQA S 2213,2216,3198,3199,3203,3227,3344,3355,3408,3416,3447 ++*/

struct ST {int a; int b;};

extern struct ST st;
extern int      *pi;

void bar(void);

void foo(int m, int n)
{
    int r;

    r = st && m;          /* Message 0536               */
    r = st || m;          /* Message 0536               */
    r = st ? m : n;       /* Message 0536               */

    r = (bar()) && m;     /* Message 0536 and also 0543 */
    r = (bar()) || m;     /* Message 0536 and also 0543 */
    r = (bar()) ? m : n;  /* Message 0536 and also 0543 */

    r = m && n;           /* OK                         */
    r = pi || m;          /* OK                         */
}

See also:

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