[previous] MISRA C:2012  Rule-11.6:  (Required) [next] A cast shall not be performed between pointer to void and an arithmetic type

Exception:

An integer constant expression with value 0 may be cast into pointer to void.

Example Code:


#pragma PRQA_MESSAGES_OFF 2982

#include "misra.h"
#include "m3cmex.h"

extern int16_t rule_1106( void )
{
    void * pv;

    pv = (void *)0x1234u;                       /*  0306 */      /* Not compliant */
    pv = (void *)1024.0f;                       /*  0301 */      /* Not compliant */
    pv = (void *)0;
    u32a = (uint32_t)pv;                        /*  0306 */      /* Not compliant */

    return 0;
}



QAC messages that encompass this guideline:

0306 [I] Cast between a pointer to object and an integral type.


Related rules:

Rule-11.4 A conversion should not be performed between a pointer to object and an integer type



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