[previous] MISRA C:2012  Rule-11.5:  (Advisory) [next] A conversion should not be performed from pointer to void into pointer to object

Exception:

A null pointer constant that has type pointer to void may be converted into pointer to object.

Example Code:


#pragma PRQA_MESSAGES_OFF 2982,2983,3408,3447

#include <stdlib.h>
#include "misra.h"
#include "m3cmex.h"

extern int16_t rule_1105( void )
{
    void * pv = NULL;
    int16_t  * pi;

    pi = (int16_t *)pv;                         /* 0316 */
    pi =        pv;                             /* 0317 */
    pi = NULL;                                  /*      */
    pi = (void *)0;                             /*      */

    return 0;
}


QAC messages that encompass this guideline:

0316 [I] Cast from a pointer to void to a pointer to object type.
0317 [I] Implicit conversion from a pointer to void to a pointer to object 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