Menu

Access of moved variable '('. [accessMoved] <- parsing error?

Martin
2021-10-07
2021-10-08
  • Martin

    Martin - 2021-10-07

    Hi,

    there seems to be a parsing error on the current head for the following code:

    void foo()
    {
       std::unique_ptr<int> g;
       std::unique_ptr<int> f;
       g = std::move(f);
       if( (NULL == g.get()) && (NULL != f.get()))
       {
          g = std::move(f);
       }
    }
    

    Result:

    file.cpp:6:43: warning: Access of moved variable '('. [accessMoved]
       if( (NULL == g.get()) && (NULL != f.get()))
                                              ^
    

    Here's since when this occurred:
    old commit (no issue): 1f8adbafcf19e473b6548148c4b66293cad28089
    new commit (new issue): e3e0b380e2c895d8b0466d76f87e6c5a11bb027b

    Could you please check?

    Thanks,
    Martin

     
  • Daniel Marjamäki

    as far as I see it's technically a true positive. it indicates f.get(). It's the printout that does not print the whole expression just the "(".

     
  • Paul Fultz

    Paul Fultz - 2021-10-08

    as far as I see it's technically a true positive. it indicates f.get(). It's the printout that does not print the whole expression just the "(".

    Actually, its a false positive because unique_ptr is guaranteed to be null after move. We should change after move analysis to set the value to null rather than a movedValue.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.