[Python-Dev] Re: sre warnings
Tim Peters
tim.one at comcast.net
Sat Jan 10 01:02:04 EST 2004
[Gustavo Niemeyer]
> Ohh.. I wasn't aware about this case, since I get no errors at all at
> this line.
I think Martin is using a more-recent version of gcc than most people here.
Everyone on Windows (MSVC) sees these warnings, though.
> Do you see any others?
Windows doesn't complain about the ones your compiler complains about; it
complains about 17 others, listed here (although the line numbers have
probably changed in the last 3 months <wink>):
http://mail.python.org/pipermail/python-dev/2003-October/039059.html
I personally get these:
>
> Modules/_sre.c:381: warning: comparison is always true due to limited
> range of data type
> Modules/_sre.c:383: warning: comparison is always true due to limited
> range of data type
> Modules/_sre.c:390: warning: comparison is always true due to limited
> range of data type
> Modules/_sre.c:392: warning: comparison is always true due to limited
> range of data type
> Modules/_sre.c: In function `sre_charset':
> Modules/_sre.c:487: warning: comparison is always true due to limited
> range of data type
> Modules/_sre.c: In function `sre_ucharset':
> Modules/_sre.c:487: warning: comparison is always true due to limited
> range of data type
>
> Suggestions welcome.
Upgrade to Windows <heh>.
Most of those seem to come from lines of the form
SRE_LOC_IS_WORD((int) ptr[-1]) : 0;
where
SRE_CHAR* ptr
and either
#define SRE_CHAR unsigned char
or
#define SRE_CHAR Py_UNICODE
and
#define SRE_LOC_IS_WORD(ch) (SRE_LOC_IS_ALNUM((ch)) || (ch) == '_')
#define SRE_LOC_IS_ALNUM(ch) ((ch) < 256 ? isalnum((ch)) : 0)
So it's apparently bitching about
(((int) ptr[-1])) < 256
when the "unsigned char" expansion of SRE_CHAR is in effect. I suppose that
could be repaired by defining SRE_LOC_IS_ALNUM differently depending on how
SRE_CHAR is defined.
The warning on line 487 comes from
if (ch < 65536)
where
SRE_CODE ch
and SRE_CODE is unsigned short or unsigned long, depending on
Py_UNICODE_WIDE. This warning is really irritating. I suppose
#if defined(Py_UNICODE_WIDE) || SIZEOF_SHORT > 2
if (ch < 65536)
#endif
block = ((unsigned char*)set)[ch >> 8];
#if defined(Py_UNICODE_WIDE) || SIZEOF_SHORT > 2
else
block = -1;
#endif
would shut it up, but that's sure ugly.
More information about the Python-Dev
mailing list