Article View: comp.std.c
Article #4303Re: Pointer comparisons 2
From: Daniel Villeneuve
Date: Mon, 30 Oct 1995 03:05
Date: Mon, 30 Oct 1995 03:05
42 lines
2555 bytes
2555 bytes
In article <46jiqv$pl9@solutions.solon.com> diamond@jrd.dec.com (Norman Diamond) writes: > In article <46cu3i$6fg@solutions.solon.com>, danielv@crt0.crt (Daniel Villeneuve) writes: > >Note that `undefined result' seems different, as of my reading of the > >standard, from `undefined behavior'. > > I agree. Me too, but Clive D.W. Feather <clive@stdc.demon.co.uk> said, on the same question: ] There is a separate term "unspecified" which means a valid, but not ] described, result. Undefined result is the same as undefined behaviour. I cannot decide on that, because neither `unspecified result' nor `undefined result' are defined in the standard in section 1.6. > However, qsort() or bsearch() has to be called with an array in the first > place. It can be an array of structures but not a list of structures. > So, I guess you're not trying to call qsort() or bsearch(). What do you > mean by a conforming comparison function? Maybe the expression `a conforming comparison function' is not clear. In the context of my previous article (keeping ordered sets of structures), I wanted a comparison function that could be called by a sorting device (such as an AVL tree interface) to order items unambiguously, given that no two items were the same. No more hypotheses are made on those items. After having read the previous replies about that article, I agree that the comparison operators < and >, if fed with invalid arguments, could lead to `undefined result' that could be like random (if the result exists). So my comparison functions, to be conforming, should rely on some unique identifier in the structures (such as an integer telling the position of the structure in the global list), instead of the pointer on each structure, even though this pointer _is_ a unique identifier for the structure. As Stephen Baynes <baynes@ukpsshp1.serigate.philips.nl> said, ] It is a bit annoying that there is no full ordering on pointers as are a ] number of occasions it would be useful. --Daniel
Technical Details
Message-ID:
<DANIELV.95Oct29220521@crt0.crt>Path:
arc1-ca.pugleaf.net!feed.umontreal.ca!usenetReferences:
<46cu3i$6fg@solutions.solon.com> <46jiqv$pl9@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!feed.umontreal.ca!usenet From: danielv@crt0.crt (Daniel Villeneuve) Newsgroups: comp.std.c Subject: Re: Pointer comparisons 2 Date: 30 Oct 1995 03:05:21 GMT Organization: Universite de Montreal Distribution: world Message-ID: <DANIELV.95Oct29220521@crt0.crt> References: <46cu3i$6fg@solutions.solon.com> <46jiqv$pl9@solutions.solon.com> Reply-To: danielv@crt.umontreal.ca NNTP-Posting-Host: crt0.crt.umontreal.ca In-reply-to: diamond@jrd.dec.com's message of 24 Oct 1995 15:37:51 -0500