https://github.com/python/cpython/commit/c78b5a05b45817e2c2a3aa702d726f4f8cf2ae3e commit: c78b5a05b45817e2c2a3aa702d726f4f8cf2ae3e branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: vstinner <[email protected]> date: 2026-10-09T22:11:17+02:00 summary:
[3.15] gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) (#158965) gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) Initialize all fields in the macro. Otherwise, g++ -Wall -Wextra complains that some fields are not initialized [-Werror=missing-field-initializers]: error: missing initializer for member ‘PySlot::sl_flags’ error: missing initializer for member ‘PySlot::<anonymous>’ error: missing initializer for member ‘PySlot::<anonymous>’ (cherry picked from commit ba9d96ff8d7c572a0c90f072102d54b1fc3044dc) Co-authored-by: Victor Stinner <[email protected]> files: A Misc/NEWS.d/next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst M Include/slots.h diff --git a/Include/slots.h b/Include/slots.h index 4bf7bda0208a8d..4afdfd3dcc3107 100644 --- a/Include/slots.h +++ b/Include/slots.h @@ -42,7 +42,7 @@ struct PySlot { #define PySlot_STATIC_DATA(NAME, VALUE) \ {.sl_id=(NAME), .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)} -#define PySlot_END {0} +#define PySlot_END {0, 0, {0}, {_Py_NULL}} // Macros without designated initializers (for C++11 and below): diff --git a/Misc/NEWS.d/next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst b/Misc/NEWS.d/next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst new file mode 100644 index 00000000000000..3861d23e27f8b3 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst @@ -0,0 +1,2 @@ +Fix the :c:macro:`PySlot_END` macro for C++: initialize all members to avoid +compiler warnings. Patch by Victor Stinner. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
