This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: constant signed/unsigned comparison warning
- To: smurf at noris dot de (Matthias Urlichs)
- Subject: Re: constant signed/unsigned comparison warning
- From: Thomas Koenig <ig25 at mvmap66 dot ciw dot uni-karlsruhe dot de>
- Date: Wed, 24 Sep 1997 11:33:23 +0200 (MET DST)
- Cc: egcs at cygnus dot com, gcc2 at cygnus dot com
- Reply-To: Thomas dot Koenig at ciw dot uni-karlsruhe dot de (Thomas König)
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.