This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Add assertions to quiet analysis warnings about array bounds.
ClosedPublic

Authored by STL_MSFT on Jun 22 2016, 4:57 PM.

Details

Summary

Add assertions to quiet analysis warnings about array bounds.

In the partial_sort tests, the N >= M assertion is just a good sanity check, to detect bogus testcases. MSVC's /analyze needs to see the i < N assertion explicitly, otherwise it worries that array[i] might be out-of-bounds. I gave those ones comments because they are technically redundant.

In eval.pass.cpp, the assertions simply say that we aren't going to try to access arrays out-of-bounds, which I assume is guaranteed by the logic of the test, but this is far from obvious, so the assertions are valuable in their own right.

Fixes MSVC warnings of the form:
warning C6385: Reading invalid data from 'array': the readable size is 'N*4' bytes, but '8' bytes may be read.
These warnings are valuable, so I'd prefer to suppress them locally instead of globally, especially given that so few places are affected.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 61627.Jun 22 2016, 4:57 PM
STL_MSFT retitled this revision from to [libcxx] [test] Add assertions to quiet analysis warnings about array bounds..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF accepted this revision.Jun 26 2016, 12:54 PM
EricWF edited edge metadata.
This revision is now accepted and ready to land.Jun 26 2016, 12:54 PM
EricWF closed this revision.Jun 26 2016, 12:55 PM

r273820.