[previous] MISRA-C:2004  Rule  6.5:  (Required) [next] Bit fields of signed type shall be at least 2 bits long.
A signed bit field of 1 bit length is not useful.

Example Code:


/* PRQA S 3205 ++ */

#include "misra.h"
#include "m2cmex.h"

extern S16 test_0605( void )
{
   struct  bitest
   {
      signed int   is_aaa: 1;           /* MISRA Violation */
      signed int         : 1;           /* MISRA Violation */
      unsigned int       : 1;
      signed int   is_bbb: 3;
      signed int         : 0;           /* MISRA Violation */
      signed int   is_ccc: 3;
      unsigned int       : 0;
      signed int   is_ddd: 3;
   } obj_0605;

   return 0;
}


QAC messages that encompass this guideline:

3659 Unnamed zero-width bit-field declared with a signed type.
3660 Named bit-field consisting of a single bit declared with a signed type.
3665 Unnamed bit-field consisting of a single bit declared with a signed type.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents