![]() |
![]() |
0702 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | |||||||
The result of the sizeof operator has been used without being explicitly cast. The value returned by sizeof is of type size_t. Because this type is implementation-defined, some coding standards recommend that the result of sizeof should always be cast to a specific unsigned integral type so as to remove uncertainty. The type associated with size_t in QAC can be configured using the -intrinsictype option to reflect the type implemented in any particular environment. For example:
/*PRQA S 3198,3199,3203,3408 ++*/
struct ST
{
unsigned short usm;
unsigned char uca;
unsigned char ucb;
};
extern void foo(void)
{
unsigned long ula;
ula = sizeof(struct ST); /* Message 0702 */
ula = (unsigned long)sizeof (struct ST); /* */
}
No MISRA C:2012 Rules applicable to message 0702
![]() | ||
| 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 |