From 0571dd9fc92e66d999ba8e596786ca90d812d7b7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 7 Oct 2026 14:12:32 +0200 Subject: [PATCH] gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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::’ error: missing initializer for member ‘PySlot::’ (cherry picked from commit ba9d96ff8d7c572a0c90f072102d54b1fc3044dc) Co-authored-by: Victor Stinner --- Include/slots.h | 2 +- .../next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/C_API/2026-10-05-17-09-35.gh-issue-149044.1HUiag.rst diff --git a/Include/slots.h b/Include/slots.h index 4bf7bda0208a8df..4afdfd3dcc31076 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 000000000000000..3861d23e27f8b32 --- /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.