Menu

cppcheck 2.3.1: false positive: (error) Division by zero

2021-05-18
2021-05-20
  • Waldemar Mertke

    Waldemar Mertke - 2021-05-18

    I used the online demo http://cppcheck.sourceforge.net/demo/ to verify the error.

    #include  <limits>
    
    void f()
    {
    **  [[maybe_unused]] auto intCheck = 1 / (std::numeric_limits<int>::is_integer ? 1 : 0); // **(error) Division by zero.**
    **  [[maybe_unused]] auto intCheck2 = 1 / (true ? 1 : 0); // **NO ERROR**
    }
    

    Output:

    Cppcheck 2.3
    [test.cpp:5]: (error) Division by zero.
    Done!
    
     
  • Daniel Marjamäki

    Thanks! I have created a ticket https://trac.cppcheck.net/ticket/10285

     

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.