Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2012-Rule-13.6

In this section:
Synopsis

(Required) The operand of the sizeof operator shall not contain any expression which has potential side effects

Enabled by default

Yes

Severity/Certainty

High/Medium

highmedium.png
Full description

The operand of the sizeof operator contains an expression that has potential side effects.

Coding standards
CERT EXP06-C

Operands to the sizeof operator should not contain side effects

CERT EXP06-CPP

Operands to the sizeof operator should not contain side effects

MISRA C:2012 Rule-13.6

(Required) The operand of the sizeof operator shall not contain any expression which has potential side effects

Code examples

The following code example fails the check and will give a warning:

void example(void) {
	int i;
	int size = sizeof(i++);
}

The following code example passes the check and will not give a warning about this issue:

void example(void) {
	int i;
	int size = sizeof(i);
	i++;
}