Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!netcom!teda!ditka!mcdchg!tellab5!balr!clrcom!rmartin From: rmartin@clear.com (Bob Martin) Newsgroups: comp.lang.c++ Subject: Re: Comparison functions for qsort() and bsearch() Keywords: Sun, C++ Message-ID: <1991Feb6.222244.23132@clear.com> Date: 6 Feb 91 22:22:44 GMT References: <1991Jan21.022720.20707@cbnewsk.att.com> <70271@microsoft.UUCP> <1991Feb3.195156.151@cbnewsk.att.com> Organization: Clear Communications, Inc. Lines: 37 From: jimad@microsoft.UUCP (Jim ADCOCK) >< [... some stuff deleted ...] >< I see nothing in ARM that gives one permission to >< explicitly cast back from a void* back to the original object* type. > If you refer to ARM section 4.6 there is an peculiar statement which reads: "in C++ a void* cannot be assigned to an object of any type other than a void* without an explicit cast." If we remove the double negative it becomes: "in C++ a void* can be assigned to an object of any type other than a void* only with an explicit cast." This is roundabout, but I think it refutes Jim's statement. In article <1991Feb3.195156.151@cbnewsk.att.com> hansen@pegasus.att.com (Tony L. Hansen) writes: [ ... lots of stuff about how ANSI C allows conversion of void* to any other pointer type... followed by this quote from ANSI C...] > > A pointer to any incomplete or object type may be converted to a pointer > to void and back again; the result shall compare equal to the original > pointer. > Again in ARM 4.6 Stroustrup and Ellis argue against allowing this in C++ without explicit casts on the basis that it opens up a hole in the type system. -- +-Robert C. Martin-----+:RRR:::CCC:M:::::M:| Nobody is responsible for | | rmartin@clear.com |:R::R:C::::M:M:M:M:| my words but me. I want | | uunet!clrcom!rmartin |:RRR::C::::M::M::M:| all the credit, and all | +----------------------+:R::R::CCC:M:::::M:| the blame. So there. |