Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!algor2!jeffrey From: jeffrey@algor2.uu.net (Jeffrey Kegler) Newsgroups: comp.std.c Subject: Re: struct comparison Message-ID: <1989Jul25.022949.703@algor2.uu.net> Date: 25 Jul 89 02:29:49 GMT References: <2874@solo3.cs.vu.nl> <1989Jul14.155312.2063@utzoo.uucp> <2266@auspex.auspex.com> <5210@ficc.uu.net> <2280@auspex.auspex.com> Reply-To: jeffrey@algor2.UUCP (Jeffrey Kegler) Organization: Algorists, Inc. Lines: 28 In article <2280@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >>You compare pointer values. > >Which may not always correspond to what you want; i.e., "these two >structure values have the same values in all their fields" may not be >equivalent to "the objects these structures represent are equal". If, >say, experience with Ada indicates that they are frequently equivalent, >and that people do use structure comparison heavily, that experience >might, with some care, be applicable to C; otherwise, the right thing to >do is NOT to put it into the standard, but put it into GCC or some other >compiler and see how often it's really used. Precisely right. If we were arbitrarily stuck with an untested interpretation of structure comparison, we might soon regret it. I have my guess as the best way to compare structures by default (ignore unions and padding, compare pointers by value), but any guess that winds up in the standard we would be stuck with for a long time to come. The proper way to lobby for your favorite method of structure comparison is to hack GCC, and submit it to a jury of our peers. Just sticking a best guess into a standard is not a good idea. The ANSI C Committee deserves congratulations for having recognized this. -- Jeffrey Kegler, President, Algorists, jeffrey@algor2.UU.NET or uunet!algor2!jeffrey 1762 Wainwright DR, Reston VA 22090