www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/18/11:53:24

Date: Thu, 18 May 2000 17:37:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Alexei A. Frounze" <alex DOT fru AT mtu-net DOT ru>
cc: djgpp AT delorie DOT com
Subject: Re: C++, complex, etc
In-Reply-To: <3923BDE1.737AEF47@mtu-net.ru>
Message-ID: <Pine.SUN.3.91.1000518173156.15189C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 18 May 2000, Alexei A. Frounze wrote:

> Does that mean I need to put (int) and (size_t), if I want to assign a value
> of int to size_t and vice virsa?

In general, you don't want to assign int to size_t or vice versa.  Mixing 
signed and unsigned means trouble.

If you pass an int to a function that expects size_t, and the prototype 
is visible to the compiler, the compiler will do the casting for you, but 
it is up to you to make sure this works.  For example, passing a negative 
value to a function that expects a size_t argument is usually not a good 
idea ;-).

> OK, if it's so important, how many bugs are caused by not caring about
> size_t?

Plenty.  That's why the feature of GCC whereby it warns about comparing 
signed and unsigned is so important.

> I don't mean in my own programs. Let's say in M$'...

I have never looked at any of Microsoft's sources.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019