[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

STINNER Victor report at bugs.python.org
Wed Jan 26 09:29:28 EST 2022


STINNER Victor <vstinner at python.org> added the comment:

IMO making the assumption that "char" is signed or not in C code is bad. If Python has code like that, it must be signed to explicitly use one of these types: unsigned char or uint8_t, signed char or int8_t. Hopefully, Python can now use C99 <stdint.h> since Python 3.6.

On my x86-64 Fedora 35 (GCC 11.2.1), the "char" type is signed. I built Python with -funsigned-char and I ran the test suite: the whole test suite pass! Commands:

---
make distclean
./configure --with-pydebug CFLAGS="-O0 -funsigned-char" --with-system-expat --with-system-ffi
make
./python -m test -j0 -r
---

Using ./configure CFLAGS, -funsigned-char is also used to build C extensions. Example: 

   gcc (...) -O0 -funsigned-char (...) Modules/_elementtree.c (...)


For completeness, I also built Python with -fsigned-char. Again, the full test suite passed ;-)

---
make distclean
./configure --with-pydebug CFLAGS="-O0 -fsigned-char" --with-system-expat --with-system-ffi
make
./python -m test -r -j0
---

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46513>
_______________________________________


More information about the Python-bugs-list mailing list