Menu

Defects: false positive

Ruth Brown
2025-11-19
2025-11-20
  • Ruth Brown

    Ruth Brown - 2025-11-19

    ==> claim <==
    style: Return value '++energy_!=0' is always true [knownConditionTrueFalse]

    bool Racer::rest() { return ++energy_ != 0; }
    

    ==> rebuttal <==
    Incrementing the maximum size_t always wraps around to 0.

    #include <iostream>
    #include <cstddef>
    #include <limits>
    
    int main() {
        size_t x = std::numeric_limits<size_t>::max();
        x++;
        std::cout << x << "\n";  // prints 0
    }
    
     
  • CHR

    CHR - 2025-11-20
     

Log in to post a comment.