[previous] MISRA-C:2004  Rule  11.2:  (Required) [next] Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object type or a pointer to void.
Such conversions are undefined. This rule means that an object pointer can be converted to or from:
  1. An integral type;
  2. Another pointer to object type;
  3. A pointer to void.
No other conversions involving object pointers are permitted.

Example Code:


/* PRQA S 2982,3203 ++ */

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

extern S16 test_1102( void )
{
   F32 *  pf32 = 0;
   void * pv = 0;

   f32a = ( F32 )pf32;                  /* MISRA Violation */
   f64a = ( F64 )pf32;                  /* MISRA Violation */

   f32a = ( F32 )pv;                    /* MISRA Violation */
   f64a = ( F64 )pv;                    /* MISRA Violation */

   return 0;
}


QAC messages that encompass this guideline:

0301 [u] Cast between a pointer to object and a floating type.


Related rules:

Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(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