Created on 2018-01-24.00:00:00 last changed 46 months ago
Proposed resolution:
This wording is relative to N4713.
Modify [specialized.algorithms] as indicated:
-1- […]
Unless otherwise specified, if an exception is thrown in the following algorithms objects constructed by a placement new-expression ([expr.new]) are destroyed in an unspecified order before allowing the exception to propagatethere are no effects.
Modify [uninitialized.move] as indicated (The removed paragraphs are now unnecessary):
template<class InputIterator, class ForwardIterator> ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);[…]
-2- Remarks: If an exception is thrown, some objects in the range [first, last) are left in a valid but unspecified state.template<class InputIterator, class Size, class ForwardIterator> pair<InputIterator, ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);[…]
-4- Remarks: If an exception is thrown, some objects in the range [first, std::next(first, n)) are left in a valid but unspecified state.
[ 2018-11, Adopted in San Diego ]
[ 2018-06 Rapperswil Thursday issues processing ]
Status to Ready
[ 2018-02-05, Priority set to 2 after mailing list discussion ]
[ 2018-01-24, Casey comments and provides wording ]
This issue points out a particular hole in the "..if an exception is thrown in the following algorithms there are no effects." wording for the "uninitialized" memory algorithms ([specialized.algorithms]/1) and suggests a PR to patch over said hole. The true problem here is that "no effects" is not and never has been implementable. For example, "first != last" may have observable effects that an implementation is required to somehow reverse if some later operation throws an exception.
Rather than finding problem case after problem case and applying individual patches, we should fix the root cause. If we alter the problematic sentence from [specialized.algorithms]/1 we can fix the issue once and for all and have implementable algorithms.I believe that uninitialized_copy is unable to meet its exception-safety guarantee in the presence of throwing move constructors:
[specialized.algorithms]/1 has two statements of note for the specialized algorithms such as uninitialized_copy:the provided iterators satisfy the InputIterator requirements ([input.iterators])
if an exception is thrown during the algorithm then there are no effects
History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-25 10:48:01 | admin | set | status: wp -> c++20 |
2018-11-12 04:39:29 | admin | set | messages: + msg10191 |
2018-11-12 04:39:29 | admin | set | status: voting -> wp |
2018-10-08 05:13:59 | admin | set | status: ready -> voting |
2018-06-12 04:35:59 | admin | set | messages: + msg9911 |
2018-06-12 04:35:59 | admin | set | status: new -> ready |
2018-02-08 18:38:38 | admin | set | messages: + msg9672 |
2018-01-25 18:32:50 | admin | set | messages: + msg9638 |
2018-01-25 18:32:50 | admin | set | messages: + msg9637 |
2018-01-24 00:00:00 | admin | create |