From: j DOT aldrich6 AT genie DOT com Message-Id: <199604100422.AA174910158@relay1.geis.com> Date: Wed, 10 Apr 96 04:00:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re: A Proper Cast for a Funtio Reply to message 2504589 from JETMAN AT GNN DOT CO on 04/09/96 2:15PM >in order to cast down to a smaller type) when a cast is requested. Any >other type cast would be inherently unsafe and dangerous, so everything >would have to be re-coded to use some other data respresentation >scheme. This *must* be true, otherwise the ANSI std qsort() routine >couldn't work. That doesn't make any sense! What about integer to float conversions? If the compiler didn't do translation from one type to the other, it would result in chaos. (Imagine reading a 4-byte integer as an 8-byte double...) Or are you distinguishing between typecasting and promotion/demotion in expressions? I agree that to physically modify the data when performing a cast on a pointer type, for example, would be insane, but that isn't the idea anyway, is it? Besides, functions like qsort() don't actually perform any type-dependent operations on the lists they are passed - it's up to the comparison function to do that. And typecasting to const void * is meaningless except to establish that a given piece of data is 'generic', and can actually be anything at all. That's the basic principle on which qsort(), etc., work. John