Versions Compared

Key

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

...

In the example below, assuming that sizeof(buf) is equal sizeof(size_t) + (sizeof(char) * 50), which would equal 54 (assuming sizeof(size_t) is 4) is may be incorrect. The sizeof(buf) may actually evaluate to a larger value due to structure padding.

Code Block
struct buffer {
    size_t size;
    char buffer[50];
};

...
if (sizeof(buf) == (sizeof(size_t) + (sizeof(char)*50))) {
  /* This may not be true */
}
...

...