You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing cffi with Python 3.12 on Centos Stream 8, with GCC version 8.5.0, the tests were failing as they are using -Werror and -Wsign-conversion.
More specifically they were failing with:
./Include/cpython/longintrepr.h: In function ‘_PyLong_CompactValue’:
./Include/cpython/longintrepr.h:121:23: warning: conversion to ‘Py_ssize_t’ {aka ‘long int’} from ‘long unsigned int’ may change the sign of the result [-Wsign-conversion]
Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
The offending line was introduced in 9392379 for Python> = 3.12
That means that for GCC >= 10, the same warning can be seen again by using -Wsign-conversion and -Warith-conversion together.
The issue is easily fixed by casting to Py_ssize_t however, as indicated by the gcc bugzilla, it's debatable if there should even be a warning for those cases.
I don't see any value in working around a warning that was removed in later versions of the compiler. Especially when there are only two cases to consider, and both are tested.
If this starts warning again in the future, let's add a cast at that point.
Tightening the default warnings could be considered, bit that'd be a different issue.
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
When testing cffi with Python 3.12 on Centos Stream 8, with GCC version 8.5.0, the tests were failing as they are using -Werror and -Wsign-conversion.
More specifically they were failing with:
The offending line was introduced in 9392379 for Python> = 3.12
However that wasn't the case with later compiler versions so after a little digging I was pointed to https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=c77074d05691053ee7347d9e44ab89b3adb23fb1 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
That means that for GCC >= 10, the same warning can be seen again by using -Wsign-conversion and -Warith-conversion together.
The issue is easily fixed by casting to Py_ssize_t however, as indicated by the gcc bugzilla, it's debatable if there should even be a warning for those cases.
Would a fix even be considered for this case?
See also: #112301
CPython versions tested on:
3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: