PiotrZSL added inline comments.
================ Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp:1304 + std::unique_ptr<A> a; + a->foo(std::move(a)); +} ---------------- mboehme wrote: > PiotrZSL wrote: > > What about scenario like this: > > > > ``` > > b.foo(a->saveBIntoAAndReturnBool(std::move(b))); > > ``` > > > > Is first "b" still guaranteed to be alive after std::move ? > I'm not exactly sure what you're asking here... or how this scenario is > materially different from the other scenarios we already have? > > > Is first "b" still guaranteed to be alive after std::move ? > > The `b` in `b.foo` is guaranteed to be evaluated before the call > `a->saveBIntoAAndReturnBool(std::move(b))` -- but I'm not sure if this is > what you're asking? > > Or are you asking whether the `a->saveBIntoAAndReturnBool(std::move(b))` can > cause the underlying object to be destroyed before the call to `b.foo` > happenss? In other words, do we potentially have a use-after-free here? > > I think the answer to this depends on what exactly > `saveBIntoAAndReturnBool()` does (what was your intent here?). I also think > it's probably beyond the scope of this check in any case, as this check is > about diagnosing use-after-move, not use-after-free. I see this ```b.foo(a->saveBIntoAAndReturnBool(std::move(b)));``` like this: we call saveBIntoAAndReturnBool, that takes b by std::move, then we call foo on already moved object. For me this is use after move, that's why I was asking. And in "b.foo" there is almost nothing to evaluate, maybe address of foo, but at the end foo will be called on already moved object. If we would have something like "getSomeObj(b).boo(std::move(b))" then we can think about "evaluate", but when we directly call method on moved object, then we got use after move Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145581/new/ https://reviews.llvm.org/D145581 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits