[libcxx-commits] [PATCH] D156783: [libc++] Fix `std::out_of_range` thrown from `basic_stringbuf::str() &&`
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 1 10:43:37 PDT 2023
Mordante added inline comments.
================
Comment at: libcxx/include/sstream:405
+ if (!__view.empty())
+ __result.assign(std::move(__str_), __view.data() - __str_.data(), __view.size());
__str_.clear();
----------------
pfusik wrote:
> Mordante wrote:
> > Depending on the order of evaluation `__view.data() - __str_.data()` may be used after `__str_` has been moved. Lets determine the size before `assign`. This is pre-existing.
> >
> > Whether this is save depends on the order in which the function arguments are evaluated. Clang and GCC use a different order.
> I was also having this concern for a moment. :) But `std::move` is just a cast that does not modify its argument. The actual move is inside `assign`.
Good point, you're right. It only does a cast and nothing else.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156783/new/
https://reviews.llvm.org/D156783
More information about the libcxx-commits
mailing list