[libcxx-commits] [PATCH] D151223: [libc++] Fixes use-after move diagnostic.
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 30 09:06:02 PDT 2023
philnik added a comment.
I still don't understand what extension is supposed to be used. Not a single compiler complains about casting an rvalue to a base: https://godbolt.org/z/bv4Moh5on
================
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)
{
----------------
ldionne wrote:
> 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?
TBH the `std::move` makes more sense to me than the `static_cast`, which IMO would warrant a comment.
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