[previous] 0307 [next] [u] Cast between a pointer to object and a pointer to function.
Implicitly undefined REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics

A cast has been performed between a pointer to function type and a pointer to object type ( or vice versa ). Casts of this type are not defined in the C language.

For example:


/*PRQA S 2017,2211,3198,3199,3203,3205,3227,3408,3672,3673 ++*/

extern void foo(int * pia, void * pva, int (*pfa)(void))
{
    int  * pib;
    void * pvb;
    int (* pfb)(void);

    pib = (int *)pfa;                   /* Message 0307 */
    pvb = (void *)pfa;                  /* Message 0307 */

    pfb = (int (*)(void))pia;           /* Message 0307 */
    pfb = (int (*)(void))pva;           /* Message 0307 */
}


MISRA-C:2004 Rules applicable to message 0307:

Rule  1.2  (Required) No reliance shall be placed on undefined or unspecified behaviour.
Rule  11.1  (Required) Conversions shall not be performed between a pointer to a function and any type other than an integral type.


QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents