From 2d3abde3523b47d22d813d89a6f31a489ca08a1c Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 19 May 2024 17:22:13 +0800 Subject: [PATCH] Update common.h --- include/pocketpy/common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/pocketpy/common.h b/include/pocketpy/common.h index a6e3491d..26e81406 100644 --- a/include/pocketpy/common.h +++ b/include/pocketpy/common.h @@ -188,15 +188,17 @@ struct PyVar final{ // uninitialized PyVar() = default; + + /* We must initialize all members to allow == operator to work correctly */ // constexpr initialized constexpr PyVar(const const_sso_var&, Type type, int value): type(type), is_sso(true), flags(0), _0(value), _1(0) {} // zero initialized constexpr PyVar(std::nullptr_t): type(0), is_sso(false), flags(0), _0(0), _1(0) {} // PyObject* initialized (is_sso = false) - PyVar(Type type, PyObject* p): type(type), is_sso(false), flags(0), _1(reinterpret_cast(p)) {} + PyVar(Type type, PyObject* p): type(type), is_sso(false), flags(0), _0(0), _1(reinterpret_cast(p)) {} // SSO initialized (is_sso = true) template - PyVar(Type type, T value): type(type), is_sso(true), flags(0) { + PyVar(Type type, T value): type(type), is_sso(true), flags(0), _0(0), _1(0) { static_assert(sizeof(T) <= 12, "SSO size exceeded"); as() = value; }