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

A bit-field of unsigned type is being converted to type unsigned int under the rules of integral promotion.

This type of conversion will occur whenever an unsigned bit-field is the same size as an int and is used as an operand to one of the following operators:

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

For example:


/*PRQA S 2017,3131,3408,3447,3602,3621 ++*/

struct ST
{
    unsigned int uib1:20;
    unsigned int uib2:32;
    unsigned int uib3:12;
};

extern struct ST     stx;
extern unsigned int  ur;

extern void foo(void)
{
    ur = ~stx.uib2;                           /* Message 2122 */
}

See also:

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