Menu

cppcheck 1.90 AS broken issue.

2020-02-14
2020-02-14
  • Adnan Shaheen

    Adnan Shaheen - 2020-02-14

    While using the latest cppcheck I found an issue with the following error

    error: Syntax Error: AST broken, 'if' doesn't have two operands. [internalAstError]
    This error happens when I do the following

    HANDLE fileHandle = INVALID_HANDLE_VALUE;
    auto func = call_to_fun([&fileHandle]() { if (fileHandle != INVALID_HANDLE_VALUE) closeHandle(fileHandle) });
    

    I was looking in the cppcheck code in tokenlist.cpp in order to see what's wrong. It looks like this shouldn't be a problem as it is lembda. In fact, if I move the code little bit

    HANDLE fileHandle = INVALID_HANDLE_VALUE;
    auto lembda_func = [&fileHandle]() { if (fileHandle != INVALID_HANDLE_VALUE) closeHandle(fileHandle) };
    auto func = call_to_fun(lembda_func);
    

    So i'm not sure if i'm doing it wrong or it is actually a bug in cppcheck 1.90

     

    Last edit: Adnan Shaheen 2020-02-14
  • Daniel Marjamäki

    Probably a Cppcheck bug. Can you please provide a small example code that reproduce the problem?

     
  • Paul Fultz

    Paul Fultz - 2020-02-14

    This maybe related to this bug here:

    https://trac.cppcheck.net/ticket/9537

     
  • Adnan Shaheen

    Adnan Shaheen - 2020-02-14

    Yep, this is the same problem. Thanks guys. Hoping to see it get fixed, I may look into it myself :-)

     

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.