...
The operand passed to_Alignof
is never evaluated, despite not being an expression. For instance, if the operand is a VLA type and the value of the VLA's size expression contains a side effect, that side effect is never evaluated.
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> void func(void) { int a = 14; int b = sizeof(a); ++a; printf("%d, %d\n", a, b); } |
...
Noncompliant Code Example (sizeof
, VLA)
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stddef.h>
#include <stdio.h>
void f(size_t n) {
/* n must be incremented */
size_t a = sizeof(int[++n]);
/* n need not be incremented */
size_t b = sizeof(int[++n % 1 + 1]);
printf("%z, %z, %z\n", a, b, n);
/* ... */
}
|
...
Compliant Solution (sizeof
, VLA)
...