Mail Archives: djgpp/1996/04/10/00:40:00
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
- Raw text -