@@ -103,8 +103,8 @@ class thread_specific_storage {
103103
104104 T *get () const { return reinterpret_cast <T *>(PYBIND11_TLS_GET_VALUE (key_)); }
105105
106- operator T *() const { return get (); }
107106 T &operator *() const { return *get (); }
107+ explicit operator T *() const { return get (); }
108108 explicit operator bool () const { return get () != nullptr ; }
109109
110110 void set (T *val) { PYBIND11_TLS_REPLACE_VALUE (key_, reinterpret_cast <void *>(val)); }
@@ -227,7 +227,7 @@ struct internals {
227227 std::unordered_map<PyTypeObject *, std::vector<type_info *>> registered_types_py;
228228#ifdef Py_GIL_DISABLED
229229 std::unique_ptr<instance_map_shard[]> instance_shards; // void * -> instance*
230- size_t instance_shards_mask;
230+ size_t instance_shards_mask = 0 ;
231231#else
232232 instance_map registered_instances; // void * -> instance*
233233#endif
@@ -251,14 +251,14 @@ struct internals {
251251
252252 type_map<PyObject *> native_enum_type_map;
253253
254- internals () {
254+ internals ()
255+ : static_property_type(make_static_property_type()),
256+ default_metaclass (make_default_metaclass()) {
255257 PyThreadState *cur_tstate = PyThreadState_Get ();
256258 tstate = cur_tstate;
257259
258260 istate = cur_tstate->interp ;
259261 registered_exception_translators.push_front (&translate_exception);
260- static_property_type = make_static_property_type ();
261- default_metaclass = make_default_metaclass ();
262262#ifdef Py_GIL_DISABLED
263263 // Scale proportional to the number of cores. 2x is a heuristic to reduce contention.
264264 auto num_shards
@@ -539,19 +539,20 @@ class internals_pp_manager {
539539 dict state_dict = get_python_state_dict ();
540540 auto internals_obj
541541 = reinterpret_steal<object>(dict_getitemstringref (state_dict.ptr (), holder_id_));
542+ std::unique_ptr<InternalsType> *pp;
542543 if (internals_obj) {
543544 void *raw_ptr = PyCapsule_GetPointer (internals_obj.ptr (), /* name=*/ nullptr );
544545 if (!raw_ptr) {
545546 raise_from (PyExc_SystemError,
546547 " pybind11::detail::internals_pp_manager::get_pp_from_dict() FAILED" );
547548 throw error_already_set ();
548549 }
549- return reinterpret_cast <std::unique_ptr<InternalsType> *>(raw_ptr);
550+ pp = reinterpret_cast <std::unique_ptr<InternalsType> *>(raw_ptr);
550551 } else {
551- auto pp = new std::unique_ptr<InternalsType>;
552+ pp = new std::unique_ptr<InternalsType>;
552553 state_dict[holder_id_] = capsule (reinterpret_cast <void *>(pp));
553- return pp;
554554 }
555+ return pp;
555556 }
556557
557558 char const *holder_id_ = nullptr ;
0 commit comments