[llvm-bugs] [Bug 50224] New: std::forward_list::swap noexcept specification not using correct member type
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 4 23:44:56 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50224
Bug ID: 50224
Summary: std::forward_list::swap noexcept specification not
using correct member type
Product: libc++
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: p.hyundeok76 at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
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_);
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210505/888c19e3/attachment-0001.html>
More information about the llvm-bugs
mailing list