Skip to content

Conversation

philnik777
Copy link
Contributor

No description provided.

@philnik777 philnik777 marked this pull request as ready for review September 24, 2025 13:49
@philnik777 philnik777 requested a review from a team as a code owner September 24, 2025 13:49
@philnik777 philnik777 merged commit 9cd0279 into llvm:main Sep 24, 2025
74 of 75 checks passed
@philnik777 philnik777 deleted the fix_hash_multiset branch September 24, 2025 13:49
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/160466.diff

2 Files Affected:

  • (modified) libcxx/include/ext/hash_set (+1-4)
  • (added) libcxx/test/extensions/gnu/hash_multiset/copy.pass.cpp (+27)
diff --git a/libcxx/include/ext/hash_set b/libcxx/include/ext/hash_set
index 62a7a0dbcffb9..2796774fee24a 100644
--- a/libcxx/include/ext/hash_set
+++ b/libcxx/include/ext/hash_set
@@ -534,10 +534,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
 }
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
-hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {
-  __table_.__rehash_multi(__u.bucket_count());
-  insert(__u.begin(), __u.end());
-}
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {}
 
 template <class _Value, class _Hash, class _Pred, class _Alloc>
 template <class _InputIterator>
diff --git a/libcxx/test/extensions/gnu/hash_multiset/copy.pass.cpp b/libcxx/test/extensions/gnu/hash_multiset/copy.pass.cpp
new file mode 100644
index 0000000000000..84c14bd18b085
--- /dev/null
+++ b/libcxx/test/extensions/gnu/hash_multiset/copy.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated
+
+// hash_multiset::hash_multiset(const hash_multiset&)
+
+#include <cassert>
+#include <ext/hash_set>
+
+int main(int, char**) {
+  __gnu_cxx::hash_multiset<int> set;
+
+  set.insert(1);
+  set.insert(1);
+
+  auto set2 = set;
+
+  assert(set2.size() == 2);
+
+  return 0;
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants