[previous] 0563 [next] [C] Right operand of assignment is not of compatible pointer type.
Constraint violations REFERENCE - ISO:C90-6.3.16.1 Simple Assignment - Constraints

This is a constraint error

An object of pointer type has been assigned the value of an expression of incompatible type. This is not permitted. The assigned expression must point to a compatible (possibly less qualified) type.

For example:


/*PRQA S 750,759,2213,2216,3132,3198,3199,3203,3210,3205,3408,3447,3602,3623,3625 ++ */
struct ST1 { int si; char sbuf[10];};
union  UN1 { int ui; int uj;};

extern struct ST1 st1a;
extern union  UN1 un1a;

extern int  *pi;
extern char *pc;
extern int   gi;
extern char  cbuf[10];
extern unsigned char *puc;

extern void test(void)
{
    char *px;

    px = pi;               /* 0563                               */
    px = gi;               /* 0563                               */
    px = st1a;             /* 0563                               */
    px = un1a;             /* 0563                               */
    px = cbuf;             /* OK, array lvalue decays to pointer */
    px = pc;               /* OK                                 */
    px = puc;              /* 0563                               */
}

Note that according to ISO:C Standard 'char' and 'unsigned char' (or 'signed char') are distinct types, even though 'char' may be implemented as 'unsigned char' (or 'signed char'). For this reason message 0563 is generated for the last assignment in the example above. If your compiler incorrectly allows such a conversion, you can use QA·C option -foldplainchar (compiler personality) to mimic this behaviour.

See also:

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