[previous] 2103 [next] Integral promotion : unsigned short promoted to unsigned int.
Arithmetic type - Integral promotion REFERENCE - ISO:C90-6.2.1.1 Characters and Integers

An operand of type unsigned short is being converted to type unsigned int under the rules of integral promotion.

This type of conversion will only occur if type short is the same size as type int and an expression of type short is used as an operand of the following operators:

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

For example:


/*PRQA S 3408,3447,3602 ++*/
/*************************************
 * OPTIONS: -s int=16
 ************************************/

extern unsigned short ua;
extern unsigned short ub;
extern unsigned short ur;
extern unsigned int  ui;

extern void foo(void)
{
    ur = ua + ub;                             /* Message 2103 */
    ui = ~ur;                                 /* Message 2103 */
}

See also:

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