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

Vector[ ] range check: Tautological compare #9

Open
TamaMcGlinn opened this issue Jul 25, 2020 · 1 comment
Open

Vector[ ] range check: Tautological compare #9

TamaMcGlinn opened this issue Jul 25, 2020 · 1 comment

Comments

@TamaMcGlinn
Copy link

If I include std_lib_facilities.h, I get:

$ clang++ FirstStepsInCPP.cpp -std=c++14
In file included from FirstStepsInCPP.cpp:4:
./book_headers/std_lib_facilities.h:107:8: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (i<0||size()<=i) throw Range_error(i);
                    ~^~
./book_headers/std_lib_facilities.h:113:8: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (i<0||size()<=i) throw Range_error(i);
                    ~^~
2 warnings generated.

Which is absolutely true; i is an unsigned int so why bother checking for negative values?

@TamaMcGlinn
Copy link
Author

I see this is solved by pullrequest #8

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

1 participant