The current implementation of `std::forward_list::swap` is as follows: ```cpp _LIBCPP_INLINE_VISIBILITY void swap(__forward_list_base& __x) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; #else _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || __is_nothrow_swappable<__node_allocator>::value); ``` which uses `propagate_on_container_move_assignment` for `noexcept` specification. This must use `propagate_on_container_swap` for checking according to [[container.requirements.general/8]](http://eel.is/c++draft/container.requirements.general#8). When the change is applied, the declaration should look like: ```cpp _LIBCPP_INLINE_VISIBILITY void swap(__forward_list_base& __x) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; #else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value); ``` and the definition should be as follows: ```cpp template <class _Tp, class _Alloc> inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT #else _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) #endif { _VSTD::__swap_allocator(__alloc(), __x.__alloc(), integral_constant<bool, __node_traits::propagate_on_container_swap::value>()); using _VSTD::swap; swap(__before_begin()->__next_, __x.__before_begin()->__next_); } ```
Thanks for the fix! commit 7adf713a5e22b44c7cc746bcd379d844277a19f2 Author: Hyundeok Park <p.hyundeok76@gmail.com> Date: Tue Jun 22 12:37:51 2021 -0400 [libc++] Change forward_list::swap to use propagate_on_container_swap for noexcept specification The current implementation of `std::forward_list::swap` uses `propagate_on_container_move_assignment` for `noexcept` specification. This patch changes it to use `propagate_on_container_swap`, as it should. Fixes https://llvm.org/PR50224. Differential Revision: https://reviews.llvm.org/D101899