[previous] 0634 [next] [I] Bit-fields in this struct/union have not been declared explicitly as unsigned or signed.
Implementation defined REFERENCE - ISO:C90-6.5.2.1 Structure and Union Specifiers - Semantics

Bit-fields have been defined without specifying explicit signedness.

According to the ISO:C Standard, a bit-field can only be defined with one of the following types:

In any other context, int is always implemented as a signed type. However, when used to define a bit-field, it may either be implemented as a signed type or as an unsigned type; behaviour is implementation-defined. In order to remove this uncertainty, it is better practice to define the signedness of a bit-field explicitly by specifying the type as either unsigned int or signed int.

In practice compilers frequently support bit-fields of other integer types (e.g. signed char, unsigned char). Message 0634 is generated if a struct or union is declared with any bit-field of type char, short, int, long or long long. The message is only generated once in any struct or union declaration.

For example:


/*PRQA S 553,2017,3131,3602,3621 ++*/

struct ST                               /* Message 0634 */
{
   int            a:5;
   unsigned int   b:4;
   signed int     c:3;
   int            d:4;
};


MISRA C:2012 Rules applicable to message 0634:

Dir-1.1  (Required) Any implementation-defined behaviour on which the output of the program depends shall be documented and understood
Rule-6.1  (Required) Bit-fields shall only be declared with an appropriate type


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents