top | item 39073414

(no title)

pardoned_turkey | 2 years ago

It's even worse: for example, the first one isn't undefined, it's merely unspecified - i.e., "depends on the system in a well-known and predictable way," not "you're doing something very wrong and the result is chaos."

discuss

order

aw1621107|2 years ago

> it's merely unspecified - i.e., "depends on the system in a well-known and predictable way,"

I think that should be implementation-defined behavior, not unspecified behavior? IIRC unspecified behavior in C is not required to be known or consistent.

plorkyeran|2 years ago

My bigger problem with the first one is that the explanation is incorrect and it isn't actually about structure padding. The explanation is making the incorrect assumption that `sizeof(int)` is always 4, but it isn't. `sizeof(*(&s))` can be as small as 2.