![]() |
![]() |
0450 | ![]() |
||||
![]() | |||||||
| Constraint violations | REFERENCE - ISO:C90-6.3.4 Cast Operators - Constraints, ISO:C90-6.2.2.1 Lvalues and Function Designators | ||||||
This is a constraint error An expression of array type is the operand of a cast. This is not permitted. The operand of a cast must always be of scalar type. An expression of array type is unusual because an lvalue of array type is always converted to an expression that has type "pointer to type". Message 450 is therefore only generated when an expression of array type is not an lvalue. For example:
/*PRQA S 310,2213,3132,3198,3199,3203,3205,3408,3447,3625,3631 ++*/
struct ST { int ai[3]; };
extern struct ST sf(void);
extern struct ST sta;
extern int ibuf[10];
void foo(void)
{
char *pc;
pc = (char *)ibuf; /* OK - ibuf decays to type pointer to int */
pc = (char *)(sta.ai); /* OK - sta.ai decays to type pointer to int */
pc = (char *)(sf().ai); /* Message 0450 and also 0481 */
pc = (char *)sta; /* Message 0481 - sta is not of scalar type */
}
MISRA-C:2004 Rules applicable to message 0450:
| Rule 1.1 (Required) | All code shall conform to ISO/IEC 9899:1990 C programming language, ISO 9899, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2: 1996192 |
See also:
![]() | ||
| 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 |