Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code analysis: potential bug? #859

Closed
aj664 opened this issue Dec 5, 2017 · 1 comment
Closed

code analysis: potential bug? #859

aj664 opened this issue Dec 5, 2017 · 1 comment

Comments

@aj664
Copy link

aj664 commented Dec 5, 2017

warning C28020: The expression '0<=Param(1)&&Param(1)<=64-1' is not true at this call.

from the your .h file: the line the above comment is pointing at is the number_buffer[i++ line.

        // make sure the number has been processed completely
        assert(x == 0);

        if (is_negative)
        {
            // make sure there is capacity for the '-'
            assert(i < number_buffer.size() - 2);
            number_buffer[i++] = '-';
        }

this code analysis tool gives off some rather strange false positives, so it might be nothing..

@nlohmann
Copy link
Owner

nlohmann commented Dec 6, 2017

The function dumps an integer of type int64_t or uint64_t to a string. The largest value for uint64_t is 18446744073709551615(20 chars), the smallest value for int64_t is -9223372036854775808 (also 20 chars), and the largest value for int64_t is 9223372036854775807 (19 chars). So after adding a null byte, we need at most 21 characters for number_buffer which has a size of 64 chars.

I think this is a false positive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants