Re: Style question: comparison between signed and unsigned?

Patrick St. Jean (psj@cgmlarson.com)
Tue, 23 Sep 1997 15:20:37 -0500 (CDT)


On this whole subject (minus side threads), I think the argument was
that it was silly to warn about the need for a typecast in a comparison
between an int and an unsigned int return value, something like this

int i;

...

if(i < some_function_that_returns_unsigned_int()){
...
}

Well, what happens if that function returns a value that has the MSBit
set? If we aren't typecasting, do we "promote" the int to unsigned? do
we "demote" the unsigned return value? Neither of these would be
acceptable to me. Dangit! I bloody well don't want to have that kind of
compiler funnies going on. Let it tell me that they're not the same data
type. In that case there's a REALLY good reason for it. Yeah, the
typecast isn't pretty, but at least I know that there is a definite
way that it is going to behave over different compilers. Sorry if I'm
rambling and/or lost the origional gist of the thread...

Pat

-- 
+----------------------------------------------------------------------------+
| Patrick St. Jean              '97 XLH 883                psj@cgmlarson.com |
| Programmer & Systems Administrator                    +1 713-977-4177 x106 |
| Larson Software Technology                        http://www.cgmlarson.com |
+----------------------------------------------------------------------------+