[cfe-dev] Use-after-move warning?

David Blaikie dblaikie at gmail.com
Tue Oct 7 08:19:01 PDT 2014


On Tue, Oct 7, 2014 at 1:00 AM, David Chisnall <David.Chisnall at cl.cam.ac.uk>
wrote:

> On 6 Oct 2014, at 21:39, David Blaikie <dblaikie at gmail.com> wrote:
>
> > I doubt it's reliable enough to warn on that generally - the user
> might've wanted to return an empty value in that situation. (think of the
> case where T is std::unique_ptr, with a well defined move-from state that
> users might rely on).
>
> I think that the number of times that I've used that pattern is a tiny
> handful of the times where I've used std::move, so perhaps an attribute to
> flag that 'yes, I really meant to return this value even though it's now
> empty' is the way forward?
>

Perhaps - I'm just suggesting some of the gotchas I'd want to keep an eye
out for when evaluating the quality of such a warning. Numbers trump
everything - if someone implements it, surveys a large codebase, and finds
few enough false positives (with reasonable ways to rewrite them to not
trigger the warning) - that's success.


>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141007/634519a4/attachment.html>


More information about the cfe-dev mailing list