This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix MSVC warning C4127 "conditional expression is constant".
AbandonedPublic

Authored by STL_MSFT on Jan 11 2017, 7:05 PM.

Details

Summary

[libcxx] [test] Fix MSVC warning C4127 "conditional expression is constant".

MSVC has a compiler warning (enabled at /W4) that's potentially useful,
although slightly annoying to library devs who know what they're doing.
In the latest version of the compiler, the warning is suppressed when the
compiler sees simple tests like "if (name_of_thing)", so extracting comparison
expressions into named constants is a workaround. This is useful for ensuring
that libraries are C4127-clean.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 84067.Jan 11 2017, 7:05 PM
STL_MSFT retitled this revision from to [libcxx] [test] Fix MSVC warning C4127 "conditional expression is constant"..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
STL_MSFT abandoned this revision.Jan 13 2017, 4:30 PM

Actually, this pattern annoys "warning C6326: Potential comparison of a constant with another constant." from /analyze. I'll figure out a better fix, probably with integral_constant.