Skip to content

Fix compilation warnings on Python 3.15 - #1077

Merged
Siyet merged 2 commits into
mainfrom
1048-fix-3.15-compilation-warnings
Jun 16, 2026
Merged

Fix compilation warnings on Python 3.15#1077
Siyet merged 2 commits into
mainfrom
1048-fix-3.15-compilation-warnings

Conversation

@Siyet

@Siyet Siyet commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Silences three compiler warnings seen on 3.15-dev (and reproducible on 3.14):

  • _constr_as_i64: (-1LL << 63) is a left shift of a negative value (UB, -Wshift-negative-value). Replaced with INT64_MIN, which is the value it was computing.
  • double_as_int64: (-1LL << 53) is the same UB. Replaced with -(1LL << 53) (negate a positive shift), keeping the exact -2**53 bound.
  • ms_passes_big_int_constraints: _PyLong_Sign is Py_DEPRECATED(3.14). Use the public PyLong_GetSign on 3.14+ and keep _PyLong_Sign on older versions.

All three are behavior preserving. Built and ran the unit suite on both branches: 3.12 (_PyLong_Sign) and 3.14 (PyLong_GetSign), both green; the three warnings are gone under 3.14 headers.

Note: the reporter's paste also mentions "1 error" alongside the warnings. That is an SSIZE_MAX undeclared from CPython's 3.15 pyport.h when _core.c is compiled in isolation without _GNU_SOURCE; it doesn't reproduce under the normal build (CPython's pyconfig.h sets the feature-test macros), so it's out of scope here.

Closes #1048

@Siyet
Siyet temporarily deployed to docs-preview June 16, 2026 11:24 — with GitHub Actions Inactive
@Siyet
Siyet added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 3483da5 Jun 16, 2026
27 checks passed
@Siyet
Siyet deleted the 1048-fix-3.15-compilation-warnings branch June 16, 2026 11:39
Comment thread src/msgspec/_core.c
#if PY314_PLUS
/* obj is always a PyLong here, so PyLong_GetSign can't fail */
int sign = 0;
PyLong_GetSign(obj, &sign);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use explicit (void)PyLong_GetSign(obj, &sign); to tell that we ignore the result value.

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

Successfully merging this pull request may close these issues.

Compilation warnings on 3.15

2 participants