Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The explicit insertion of the padding bytes into the struct should ensure that no "invisible" padding bytes are added in by the compiler, and thus the expression in static_assert should be true.

For example on IA-32Explicitly,

offsetof(struct test, c ) = 8

...

and thus, the expression should return 1.

However, if we're compiling for a different architecture and the compiler adds padding bytes, then the memory would not be contiguous and the expression would return 0.

...