intrusive icon indicating copy to clipboard operation
intrusive copied to clipboard

unordered set node undefined behavior

Open kelbon opened this issue 7 months ago • 0 comments

Im trying to use vector of buckets for dynamic extension.

My code:

      buckets.resize(buckets.size() * 2);
      myset.rehash({buckets.data(), buckets.size()});

Code compiles, but it is undefined behavior and ... Thats why:

detail/hashtable_node.hpp:

   inline bucket_impl()
   {}

   inline bucket_impl(const bucket_impl &)
   {}

   inline ~bucket_impl()
   {}

Copy constructor(its move ctor too) does nothing and its even not noexcept, so vector .resize creates invalid nodes, then .rehash works with invalid memory = segfault

..Why? And how to do it correctly?

kelbon avatar Jul 24 '25 07:07 kelbon