[PATCH] D39149: [libc++] Prevent tautological comparisons
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 10:22:55 PDT 2017
lebedev.ri added a subscriber: thakis.
lebedev.ri added a comment.
That is my diagnostic, so i guess this is the time to reply :)
In https://reviews.llvm.org/D39149#910825, @mclow.lists wrote:
> I dislike this change fairly strongly.
> I would much rather pursue a clang-based solution (since clang is being unhelpful here)
> Don't know if we can get one, though.
As i see it, there are several options:
1. Disable that warning in `libc++` cmakelists. Be careful though, i think it might disable the entire 'tautological comparison' diagnostic family.
2. Use preprocessor pragmas to disable the diagnostic for the selected code, https://reviews.llvm.org/rL315882. Brittle, ugly, effective, has the least impact. <- Best?
3. In `-Wtautological-constant-compare`, ignore any comparisons that compare with `std::numeric_limits`. Not a fan of this solution. <- Worst?
4. Disable that diagnostic by default in clang. Also, not really a fan of this solution. I implemented it because it would have caught a real bug in my code in rather shorter time, see mail <https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html>.
5. The essential problem, i *think* is much like the problem with unreachable code diagnostic, CppCon 2017: Titus Winters “Hands-On With Abseil” <https://youtu.be/xu7q8dGvuwk?t=16m5s>. The check does not know/care whether the comparison is tautological only with the current Fundamental type sizes, or always. Perhaps this is the proper heading?
6. ???
https://reviews.llvm.org/D39149
More information about the cfe-commits
mailing list