[Python-Dev] New warnings in _sre.c

Tim Peters tim.one at comcast.net
Mon Oct 20 10:15:40 EDT 2003


MSVC complains when a signed int is compared to an unsigned int.  I'm glad
it does, because the compiler silently casts the signed int to unsigned,
which doesn't do what the author probably intended if the signed int is less
than 0:

#include <stdio.h>

void main()
{
	int i = -1;
	unsigned int j = 0;
	printf("%d\n", i < j);
}

That prints 0, i.e. it is not the case that -1 < 0U.

_sre.c(852) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1021) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1035) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1109) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1131) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1192) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1230) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1267) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1285) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1287) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1294) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1314) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1344) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1362) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1384) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1476) : warning C4018: '<' : signed/unsigned mismatch
_sre.c(1492) : warning C4018: '<' : signed/unsigned mismatch




More information about the Python-Dev mailing list