[LC++]int versus unsigned int

Robert Wuest rwuest at wuest.org
Fri Sep 28 09:58:07 UTC 2001


Davide Bolcioni wrote:
> 
> Mark Phillips mark at austrics.com.au [mltuxcpp/linux-cpp list] wrote:
> 
> > Hi,
> >
> > I am having to decide whether to define things as int or as
> > unsigned int.  To date I have been using the strategy:
> >
> >       "Unless it has to be int, declare it as unsigned int."
> 
> I was bitten by this very strategy in the past and would
> 
> advise against it. Declare f(unsigned int x), call f(-1) and
> have fun tracking the bug.

This one just got me the other day:

	unsigned int cnt;
	.
	.
	.
	for( cnt=13; cnt>0; cnt-- )
		blah_blah_blah;

An infinite loop!

Robert



More information about the tuxCPProgramming mailing list