[libcxx-commits] [PATCH] D151223: [libc++] Fixes use-after move diagnostic.
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 30 08:52:02 PDT 2023
ldionne added inline comments.
================
Comment at: libcxx/include/strstream:259
_LIBCPP_INLINE_VISIBILITY
istrstream(istrstream&& __rhs)
: istream(_VSTD::move(__rhs)),
----------------
Here and below.
================
Comment at: libcxx/include/strstream:261
: istream(_VSTD::move(__rhs)),
- __sb_(_VSTD::move(__rhs.__sb_))
+ __sb_(_VSTD::move(__rhs.__sb_)) // NOLINT(bugprone-use-after-move)
{
----------------
Mordante wrote:
> ldionne wrote:
> > What is the non-standard extension? I don't understand why this code is valid and this isn't a bug? Does `istream(_VSTD::move(__rhs))` above not move the `__sb_` member? If not, would it be possible to instead do something like
> >
> > ```
> > istream(std::move(static_cast<istream&>(__rhs)))
> > ```
> >
> > to make it clear that we're only moving `__rhs` as a base class object (if that's what's going on)?
> The non-Standard part are the move operations. I've updated the description of the patch.
>
> I can make that change, it looks closer to my original edit `istream(static_cast<istream&&>(__rhs))`, but this is less subtle :-)
Yeah I think that makes it a bit more obvious. We might not even need to add a `NOLINT` annotation then?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151223/new/
https://reviews.llvm.org/D151223
More information about the libcxx-commits
mailing list