Menu

Support for C++17 if init-statement

anoy.
2020-06-17
2020-06-17
  • anoy.

    anoy. - 2020-06-17

    The following code is correct in my opinion and the variable is definitely used. Nevertheless, it generates a warning, because probably the init-statements in the if (since C++17) are not considered.

    void f()
    {
        // warning: Unused variable value 'value' [constStatement]
        if (SomeObj value; someFunc(value))
        {
            std::cout << value.str();
        }
    }
    
     
  • Daniel Marjamäki

    Thanks! I can reproduce, I created https://trac.cppcheck.net/ticket/9776

     

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.