![]() |
![]() |
3307 | ![]() |
||||
![]() | |||||||
| Side Effects | REFERENCE - ISO:C90-6.3.3.4 The sizeof Operator - Semantics | ||||||
The operand of this 'sizeof' operator is an expression which would normally result in some side effects. However the operand of a sizeof operator is never evaluated. It exists only to define the type for which sizeof will return a size. It usually makes little sense for the operand of the sizeof operator to be anything other than a type or an object identifier. For example:
/*PRQA S 489,702,2017,2211,3198,3199,3203,3227,3408,3602,3625 ++*/
long foo(int x)
{
long y;
unsigned long un;
y = x;
un = sizeof(++y ); /* Messages 3307 and 3470 */
un = sizeof(x + 1); /* Message 3470 */
return y;
}
MISRA C:2012 Rules applicable to message 3307:
| Rule-13.6 (Mandatory) | The operand of the sizeof operator shall not contain any expression which has potential side-effects |
See also:
![]() | ||
| 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 |