https://github.com/python/cpython/commit/ba9d96ff8d7c572a0c90f072102d54b1fc3044dc
commit: ba9d96ff8d7c572a0c90f072102d54b1fc3044dc
branch: main
author: Victor Stinner <[email protected]>
committer: encukou <[email protected]>
date: 2026-10-07T14:12:32+02:00
summary:
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>’
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]