Mail Archives: djgpp/2000/05/22/00:09:32
On Fri, 19 May 2000 11:03:32 +0400, "Alexei A. Frounze"
<alex DOT fru AT mtu-net DOT ru> wrote:
>"A. Sinan Unur" wrote:
>> the problem with casting an object of type size_t to int is the same as the
>> problem with casting an unsigned int to char. sure enough there may be
>> platforms where you don't loose any information in the process, but it is
>> not safe. what if size_t is 64 bits and int is 32 bits? casting how can
>> casting size_t to int be safe (even disregarding the sign issue, which is
>> bad enough).
>
>Suppose we have a string. If the string is definetely shorter than INT_MAX
>and SSIZE_MAX (say less than 32000 characters), there must be everything
>okay with type casting for strlen(), strncpy(), etc.
But if your string contains the full text of Carlo Collodi's _The
Adventures of Pinocchio_ (loaded from the Project Gutenberg etext),
and you're on a 16-bit system, things start to break down. Can you
say "buffer overflow"?
--
Damian Yerrick
"I refuse to listen to those who refuse to listen to reason."
See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html
This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses. http://www.mcafee.com/
- Raw text -