-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
signed/unsigned mismatch in Py_UNICODE_ISSPACE macro #87196
Comments
[forwarded from https://bugs.debian.org/961396] $ cat > foo.c
#include <Python.h>
int main(int argc, char *argv[])
{
Py_UNICODE x = 0;
return Py_UNICODE_ISSPACE(x);
} $ gcc -Wsign-compare -Werror $(pkg-config --cflags python3) foo.c
In file included from /usr/include/python3.9/unicodeobject.h:1026,
from /usr/include/python3.9/Python.h:97,
from foo.c:1:
foo.c: In function ‘main’:
/usr/include/python3.9/cpython/unicodeobject.h:25:11: error: comparison of integer expressions of different signedness: ‘Py_UNICODE’ {aka ‘int’} and ‘unsigned int’ [-Werror=sign-compare]
25 | ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
| ^
foo.c:7:16: note: in expansion of macro ‘Py_UNICODE_ISSPACE’
7 | return Py_UNICODE_ISSPACE(x);
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors |
Python defines Py_UNICODE as wchar_t: typedef wchar_t Py_UNICODE; Is wchar_t signed (int type) on Debian? Which is your architecture?
It says amd64. |
# 26 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h" 1 3 4
# 321 "/usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h" 3 4
typedef int wchar_t;
# 32 "/usr/include/stdlib.h" 2 3 4 [...] # 1 "/usr/include/python3.9/cpython/unicodeobject.h" 1 yes, x86_64-linux-gnu. |
Just replacing "128U" with "128" enough? |
No, it is not enough, because we do not want to use ch as index if it is negative. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: