@@ -229,13 +229,13 @@ struct value_and_holder {
229229 bool holder_constructed () const {
230230 return inst->simple_layout
231231 ? inst->simple_holder_constructed
232- : ( bool ) inst->nonsimple .holder_constructed [index];
232+ : inst->nonsimple .holder_constructed [index];
233233 }
234234 void set_holder_constructed () {
235235 if (inst->simple_layout )
236236 inst->simple_holder_constructed = true ;
237237 else
238- inst->nonsimple .holder_constructed [index] = 1 ;
238+ inst->nonsimple .holder_constructed [index] = true ;
239239 }
240240};
241241
@@ -350,7 +350,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
350350 space += t->holder_size_in_ptrs ; // holder instance
351351 }
352352 size_t flags_at = space;
353- space += size_in_ptrs (n_types); // holder constructed flags
353+ space += size_in_ptrs (n_types * sizeof ( bool ) ); // holder constructed flags
354354
355355 // Allocate space for flags, values, and holders, and initialize it to 0 (flags and values,
356356 // in particular, need to be 0). Use Python's memory allocation functions: in Python 3.6
@@ -365,7 +365,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
365365 if (!nonsimple.values_and_holders ) throw std::bad_alloc ();
366366 std::memset (nonsimple.values_and_holders , 0 , space * sizeof (void *));
367367#endif
368- nonsimple.holder_constructed = reinterpret_cast <unsigned char *>(&nonsimple.values_and_holders [flags_at]);
368+ nonsimple.holder_constructed = reinterpret_cast <bool *>(&nonsimple.values_and_holders [flags_at]);
369369 }
370370 owned = true ;
371371}
0 commit comments