Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Wordsmithing and formatting changes

...

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
bgColor#ccccff
langc
#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
bgColor#FFcccc
langc
#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)

...