[libcxx-commits] [libcxx] a9f3849 - [libc++] Counter<T>'s assignment operator shouldn't ++gConstructed
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 14 09:58:06 PST 2023
Author: Arthur O'Dwyer
Date: 2023-02-14T12:57:36-05:00
New Revision: a9f384994b9da72ba23ad8aa9450caed42fdfcf3
URL: https://github.com/llvm/llvm-project/commit/a9f384994b9da72ba23ad8aa9450caed42fdfcf3
DIFF: https://github.com/llvm/llvm-project/commit/a9f384994b9da72ba23ad8aa9450caed42fdfcf3.diff
LOG: [libc++] Counter<T>'s assignment operator shouldn't ++gConstructed
This has been here since d5f461ca03e30, but assigning into an existing
Counter object definitely doesn't create a new object. This causes the
count to "leak" higher and higher, inside algorithms based on swapping.
Added:
Modified:
libcxx/test/support/Counter.h
Removed:
################################################################################
diff --git a/libcxx/test/support/Counter.h b/libcxx/test/support/Counter.h
index 8dbdaeb360014..6a51cc991eee7 100644
--- a/libcxx/test/support/Counter.h
+++ b/libcxx/test/support/Counter.h
@@ -25,7 +25,7 @@ class Counter : public Counter_base
Counter& operator=(const Counter& rhs) { data_ = rhs.data_; return *this; }
#if TEST_STD_VER >= 11
Counter(Counter&& rhs) : data_(std::move(rhs.data_)) { ++gConstructed; }
- Counter& operator=(Counter&& rhs) { ++gConstructed; data_ = std::move(rhs.data_); return *this; }
+ Counter& operator=(Counter&& rhs) { data_ = std::move(rhs.data_); return *this; }
#endif
~Counter() { --gConstructed; }
More information about the libcxx-commits
mailing list