[previous] MISRA-C:2004  Rule  12.12:  (Required) [next] The underlying bit representations of floating-point values shall not be used.
The storage layout used for floating-point values may vary from one compiler to another, and therefore no floating-point manipulations shall be made which rely directly on the way the values are stored. The in-built operators and functions, which hide the storage details from the programmer, should be used.

Example Code:


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

#define FC (5.0F)

extern S16 test_1212( void )
{

   union utag                  /* MISRA Violation - Rule 18.4 */
   {
      F32 a;                   /* MISRA Violation */
      U32 b;
   } un;                       /* MISRA Violation - Rule 18.4 */

   un.a = FC;

   u32a =  un.b & 0x000000FFUL ;

   return 1;
}


QAC messages that encompass this guideline:

3629 Union contains member of floating 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