[previous] 2106 [next] Integral promotion : plain char promoted to signed int.
Arithmetic type - Integral promotion REFERENCE - ISO:C90-6.2.1.1 Characters and Integers

An operand of type char is being converted to type signed int under the rules of integral promotion.

This type of conversion will occur if type char is smaller than type int and an expression of type char is used as an operand of the following operators:

Unary + - ~
Multiplicative * / %
Additive + -
Bitwise Shift << >>
Relational < > <= >=
Equality == !=
Bitwise & | ^
Conditional ? : (2nd and 3rd operands)

If char is implemented as an unsigned type of the same size as int, the conversion will be to type unsigned int rather than signed int and message 2107 will be generated rather than message 2106.

For example:


/*PRQA S 3227,3408,3447,3602,3625 ++*/

extern char  pa;
extern char  pb;

extern void foo(void)
{
    pb = pa + 1;                              /* Message 2106 */
}

See also:

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