JosephKK said:
[...]
The real problem is that even if copying is done using (possibly an
internal equivalent of) memcpy(), it is quite possible to start out with
two different structs with different padding, and then assign identical
values to the members of those structs, potentially leaving only the
padding different. Any reasonable programmer would expect those two
structs to compare equal; and that requires that the comparison operator
ignores padding, and therefore must know where it is.
Of course, it's easily possible to write an implementation which works
around this by carefully keeping all padding bytes at, say, zero, at all
times. Requiring this of all implementations, though, defeats the
purpose of leaving the value of padding undefined.
Arrgh. Does the standard require struct assignment to work across
implementations?
The first time I read that sentence, I thought you were talking about
assigning a struct in one implementation to a struct in another
implementation; of course the standard doesn't require that. But to
answer the question I think you were asking, yes, the standard
requires each implementation to support struct assignment.