From -6007606807559807356
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-12-10 11:03:51 PST
Path: sparky!uunet!mdcbbs!swordfish!alanb
Newsgroups: comp.std.c++
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <ALANB.92Dec10171217@catalina.sdl.mdcbbs.com>
From: alanb@sdl.mdcbbs.com (Alan Braggins)
Date: 10 Dec 92 16:12:17 GMT
References: <1992Dec07.222242.18703@microsoft.com> 
 <1992Dec8.103218.27689@lth.se><9234423.15066@mulga.cs.mu.OZ.AU> <1992Dec10.121200.18889@ucc.su.OZ.AU>
Organization: Shape Data (Division of EDS), Cambridge UK
Nntp-Posting-Host: 134.244.153.110
In-reply-to: maxtal@extro.ucc.su.OZ.AU's message of Thu, 10 Dec 1992 12:12:00 GMT
Lines: 35

>>>>> On Thu, 10 Dec 1992 12:12:00 GMT, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) said:

> 	This seems like an excellent suggestion. It suffers only
> in those cases where we must ask whether it makes sense to 
> compare two pointers at all. For example a char* and a function
> pointer. Might not these accidentally have the same address?

> 	Similarly suppose we allowed nested functions, then
> pointers to them would need a pointer to a stack frame as well
> as the function address (or instead of?). They would be totally
> different types of objects really.

My understanding of the ANSI-C standard (prompted by some complaints
from lint) is that functions aren't objects, and that casting a
function pointer to void* is implementation dependent, so so is
comparing them with ptrcmp(void*, void*).

If imposing a total ordering over both objects and functions is
really desirable and possible, it could be a seperate function.
I think the function should become part of the standard C library,
and should have a name from ISO section 7.13 Future library directions.
"mem" seems the most appropriate prefix, but stdlib.h seems more
appropriate than strings.h, which means it should "begin with str
and a lowercase letter (followed by any combination...".

If possible, it should be implemented in such a way that it is no
slower than using "<" on pointers where that is a total ordering.
What's the current state of the library functions may be macros/
inline functions/inline functions with external linkage discussion?

--
     Alan Braggins, alanb@sdl.mdcbbs.com, abraggins@cix.compulink.co.uk
Shape Data - A division of EDS-Scicon Limited.   Cambridge, UK +44-223-316673
   "Any technology distinguishable from magic is insufficiently advanced."
 "My employer does not necessarily share my views - but I'm working on it."


