![]() |
![]() |
0695 | ![]() |
||||
![]() | |||||||
| Pointers | |||||||
A cast has been applied to the result of a call to malloc but the type of the cast is not consistent with the type supplied as operand to the sizeof operator. Is this intended ? For example:
/*PRQA S 702,1307,1336,2017,2213,2216,3132,3199,3203,3408,3447,3602,3625,3631,3672 ++*/
#include <stdlib.h>
struct st {int n; char buf[20];};
extern int ia[100];
void foo(void)
{
char *pch;
struct st *pst;
int *pi;
pch = (char *) malloc( sizeof(struct st) ); /* Message 0695 */
pst = (struct st *) malloc( sizeof(struct st) ); /* OK */
pi = (int *) malloc( sizeof(ia) ); /* Message 0695 */
}
No MISRA C:2012 Rules applicable to message 0695
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |