This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] In random tests, use real static_asserts and silence a warning.
ClosedPublic

Authored by STL_MSFT on Nov 17 2016, 1:33 PM.

Details

Summary

[libcxx] [test] In random tests, use real static_asserts and silence a warning.

One test triggers MSVC's warning C4310 "cast truncates constant value".
The code is valid, and yet the warning is valid, so I'm silencing it
through push-disable-pop.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 78411.Nov 17 2016, 1:33 PM
STL_MSFT retitled this revision from to [libcxx] [test] In random tests, use real static_asserts and silence a warning..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF edited edge metadata.Nov 17 2016, 11:11 PM

Fun libc++ fact: We implement almost all of the C++11 library in C++03.

These tests use assert because min() is not constexpr in C++03. If you don't mind please change the tests to:

#if TEST_STD_VER >= 11
static_assert(...);
#else
assert(...);
#endif

Feel free to commit after making those changes.

test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
44

Warning "4310"? #pragma GCC warning ignored "-Wwarning-name" is so much better. Your compiler is bad and you should feel bad. :-P

STL_MSFT accepted this revision.Nov 18 2016, 3:00 PM
STL_MSFT added a reviewer: STL_MSFT.

Made the requested changes, committed as r287391 with Eric's approval.

test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
44

Yeah, but C4310 is so much more searchable on the internet! :-P

This revision is now accepted and ready to land.Nov 18 2016, 3:00 PM
STL_MSFT closed this revision.Nov 18 2016, 3:00 PM