Menu

[unsignedLessThanZero] false positive after if(std::is_signed)

DougCube
7 days ago
6 days ago
  • DougCube

    DougCube - 7 days ago

    I think this is a false positive.

    template <typename T>
    constexpr T func(const T n) {
        if constexpr(std::is_signed_v<T>)
            if(n < 0) throw out_of_range(" n < 0 not allowed!");
        ...
    }
    

    style: Checking if unsigned expression 'n' is less than zero.
    [unsignedLessThanZero] if(n < 0) throw out_of_range("n < 0 not
    allowed!");

    -Doug

     

    Last edit: DougCube 6 days ago
  • CHR

    CHR - 7 days ago
     
  • DougCube

    DougCube - 6 days ago

    It looks like I was running a much older version (v2.13.0 from 2023) because that is what Ubuntu apt install gives currently. But I have now manually installed v2.19.0 and this issue is fixed.

     

Log in to post a comment.