Menu

std::min vs (std::min): different behaviour

2023-03-01
2023-03-01
  • Jens Lund Jensen

    Hi

    Using version 2.10 and online
    void f()
    {
    unsigned char test1 = 0;
    test1 = (std::min)(test1,1);
    if(test1 == 0) {
    }

    unsigned char test2 = 0;
    test2 = std::min(test2,1);
    if(test2 == 0) {
    }
    }

    result
    Cppcheck 2.10
    [test.cpp:5]: (style) Condition 'test1==0' is always false
    Done!

    cppcheck handles std::min diffrent then (std::min)

    Best regards Jens.

     
  • CHR

    CHR - 2023-03-01

    Thanks for reporting, please refer to this ticket: https://trac.cppcheck.net/ticket/11449

     

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.