[gcc r15-10512] libstdc++: Fix std::forward_list::assign assignable check [PR122661]
Jonathan Wakely
redi@gcc.gnu.org
Fri Nov 14 09:46:20 GMT 2025
https://gcc.gnu.org/g:2e9bed79a26cdf9c3b611db7b4ee6be9acf12071
commit r15-10512-g2e9bed79a26cdf9c3b611db7b4ee6be9acf12071
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Nov 13 09:45:12 2025 +0000
libstdc++: Fix std::forward_list::assign assignable check [PR122661]
The std::is_assignable check should test for assignment to an lvalue,
not an rvalue.
libstdc++-v3/ChangeLog:
PR libstdc++/122661
* include/bits/forward_list.h (forward_list::assign(I, I)): Fix
value category in is_assignable check.
* testsuite/23_containers/forward_list/modifiers/122661.cc:
New test.
(cherry picked from commit 9332dfd4523ddb100668a7c11a144a2bd676da7e)
Diff:
---
libstdc++-v3/include/bits/forward_list.h | 2 +-
.../23_containers/forward_list/modifiers/122661.cc | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index 8bcfb809319e..459b2f65ad18 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -1046,7 +1046,7 @@ namespace __fwdlist
void
assign(_InputIterator __first, _InputIterator __last)
{
- if constexpr (is_assignable<_Tp, decltype(*__first)>::value)
+ if constexpr (is_assignable<_Tp&, decltype(*__first)>::value)
{
auto __prev = before_begin();
auto __curr = begin();
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/122661.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/122661.cc
new file mode 100644
index 000000000000..41ac32c7ec6a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/122661.cc
@@ -0,0 +1,20 @@
+// { dg-do compile { target c++11 } }
+
+// Bug 122661 - Incorrect value category handling in forward_list::assign
+
+#include <forward_list>
+
+struct S
+{
+ S();
+ S& operator=(S const&) & = delete;
+ S& operator=(S const&) &&;
+};
+
+void
+test_pr122661()
+{
+ std::forward_list<S> fl;
+ S* iter = nullptr;
+ fl.assign(iter, iter);
+}
More information about the Libstdc++-cvs
mailing list