Skip to content
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

Build warnings from GCC on Python 3.12 #92

Open
stefan6419846 opened this issue Oct 16, 2023 · 2 comments
Open

Build warnings from GCC on Python 3.12 #92

stefan6419846 opened this issue Oct 16, 2023 · 2 comments

Comments

@stefan6419846
Copy link
Contributor

Re-generating the Cython code on Python 3.12 and running the build afterwards yields some build warnings:

  gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12 -c intbitset/intbitset.c -o build/temp.linux-x86_64-cpython-312/intbitset/intbitset.o
  intbitset/intbitset.c: In function ‘__pyx_pf_9intbitset_9intbitset___cinit__’:
  intbitset/intbitset.c:4246:13: warning: ‘PyObject_AsReadBuffer’ is deprecated [-Wdeprecated-declarations]
   4246 |             __pyx_t_4 = (PyObject_AsReadBuffer(__pyx_v_tmp, (&__pyx_v_buf), (&__pyx_v_size)) < 0);
        |             ^~~~~~~~~
  In file included from /opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12/Python.h:100,
                   from intbitset/intbitset.c:16:
  /opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12/abstract.h:369:17: note: declared here
    369 | PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
        |                 ^~~~~~~~~~~~~~~~~~~~~
  intbitset/intbitset.c: In function ‘__pyx_f_9intbitset_9intbitset_fastload’:
  intbitset/intbitset.c:12305:7: warning: ‘PyObject_AsReadBuffer’ is deprecated [-Wdeprecated-declarations]
  12305 |       __pyx_t_9 = (PyObject_AsReadBuffer(__pyx_v_tmp, (&__pyx_v_buf), (&__pyx_v_size)) < 0);
        |       ^~~~~~~~~
  In file included from /opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12/Python.h:100,
                   from intbitset/intbitset.c:16:
  /opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12/abstract.h:369:17: note: declared here
    369 | PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
        |                 ^~~~~~~~~~~~~~~~~~~~~
  gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/opt/hostedtoolcache/Python/3.12.0/x64/include/python3.12 -c intbitset/intbitset_impl.c -o build/temp.linux-x86_64-cpython-312/intbitset/intbitset_impl.o
  intbitset/intbitset_impl.c: In function ‘intBitSetResize’:
  intbitset/intbitset_impl.c:178:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
    178 |     if (allocated > bitset->allocated) {
        |                   ^
  intbitset/intbitset_impl.c: In function ‘intBitSetIsInElem’:
  intbitset/intbitset_impl.c:190:19: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
    190 |     return ((elem < bitset->allocated * wordbitsize) ?
        |                   ^
  intbitset/intbitset_impl.c: In function ‘intBitSetAddElem’:
  intbitset/intbitset_impl.c:195:14: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
    195 |     if (elem >= (bitset->allocated - 1) * wordbitsize) {
        |              ^~
  intbitset/intbitset_impl.c: In function ‘intBitSetDelElem’:
  intbitset/intbitset_impl.c:207:14: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
    207 |     if (elem >= (bitset->allocated - 1) * wordbitsize) {
        |              ^~
  intbitset/intbitset_impl.c: In function ‘intBitSetIsDisjoint’:
  intbitset/intbitset_impl.c:414:40: warning: passing argument 1 of ‘intBitSetAdaptMin’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    414 |   xend = x->bitset + intBitSetAdaptMin(x, y);
        |                                        ^
  intbitset/intbitset_impl.c:247:40: note: expected ‘IntBitSet * const’ but argument is of type ‘const IntBitSet *’
    247 | int intBitSetAdaptMin(IntBitSet *const x, IntBitSet *const y) {
        |                       ~~~~~~~~~~~~~~~~~^
  intbitset/intbitset_impl.c:414:43: warning: passing argument 2 of ‘intBitSetAdaptMin’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    414 |   xend = x->bitset + intBitSetAdaptMin(x, y);
        |                                           ^
  intbitset/intbitset_impl.c:247:60: note: expected ‘IntBitSet * const’ but argument is of type ‘const IntBitSet *’
    247 | int intBitSetAdaptMin(IntBitSet *const x, IntBitSet *const y) {
        |                                           ~~~~~~~~~~~~~~~~~^
@pombredanne
Copy link
Collaborator

This is still the case as of the latest Cython.
The C code is generated, so the issue is either:

  1. not fixable
  2. fixable in intbitset.pyx

Would you care digging in this for a solution?

@stefan6419846
Copy link
Contributor Author

intbitset_impl.c is not auto-generated, thus these tend to be errors which are fixable by us. Unfortunately, my general C knowledge is rather limited.

For PyObject_AsReadBuffer: They are defined inside the intbitset.pyx file and thus modifiable by us as well:

if PyObject_AsReadBuffer(tmp, &buf, &size) < 0:
if PyObject_AsReadBuffer(tmp, &buf, &size) < 0:
These have been discussed in #93 already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants