constant signed/unsigned comparison warning
Thomas Koenig
ig25@mvmap66.ciw.uni-karlsruhe.de
Wed Sep 24 04:44:00 GMT 1997
Matthias Urlichs wrote:
> And because GCC knows how to figure out the size of the struct, but then
> forgets to check if the high bit of that size is set (otherwise you cannot
> run into a problem in the first place).
The problem is that, for all the compiler knows, this might be
equivalent to
int i = random_func_which_returns_minus_10000();
if (i == -1) {
...
}
else if (i < sizeof(foo)) {
...
}
This case CAN be a problem, since the second comparison would be false,
and this could very well be a thinko on the part of the programmer.
--
Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
The joy of engineering is to find a straight line on a double
logarithmic diagram.
More information about the Gcc
mailing list