struct comparison

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Jul 15 15:22:55 AEST 1989


In article <2874 at solo3.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>Is the ANSI committee trying to tell us the compiler cannot transform the
>equality test into the correct member-by-member comparison code?

No, but apart from the padding issue it is not clear what would
constitute "equality" in practice; memberwise comparison would
seldom be what one really wanted.  Consider char* members, for
example; probably struct equality in such a case should use the
equivalent of strcmp() on those members.  Floating-point equality
tests are usually meaningless (except sometimes when one of the
operands is precisely zero).  Union members pose yet another
problem.  And so on.  Given such pratical problems, and that a
programmer can perform this test another way, and that it would
be an "invention", X3J11 chose not to require support for
aggregate equality testing.

There were an immense number of suggestions for such linguistic
enhancements received by X3J11, as listed in the introduction to
each official public review response document.  If there is much
interest, I could post the list in order to give you a better
appreciation of why such suggestions were routinely rejected.



More information about the Comp.std.c mailing list