[libcxx-commits] [PATCH] D129040: [libc++] Fix unwrapping ranges with different iterators and sentinels
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 3 03:54:47 PDT 2022
philnik added inline comments.
================
Comment at: libcxx/include/__algorithm/unwrap_range.h:39
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
+ return pair{pair{std::move(__first), nullptr}, std::move(__last)};
+ }
----------------
huixie90 wrote:
> I'd be really cautious about `nullptr`, which is comparable with pointers. if any of the logic goes wrong, it could result in a runtime UB. Is it possible to avoid `nullptr`?
How exactly would anything go wrong at runtime? This results in `pair<pair<_Iter, nullptr_t>, _Sent>`. The `nullptr_t` should only ever be passed back to `__rewrap_iter`. If that weren't the case there would be type mismatches all over the place. (i.e. `__rewrap_iter` would just return the unwrapped pointer) But anyways, just to make it //really// hard to break I'll change it to a tag type, since there isn't any downside to do so.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129040/new/
https://reviews.llvm.org/D129040
More information about the libcxx-commits
mailing list