This is an archive of the discontinued LLVM Phabricator instance.

Enable -Wtautological-unsigned-zero-compare under -Wextra
AbandonedPublic

Authored by eandrews on Aug 31 2018, 8:51 AM.

Details

Summary

GCC enables -Wtype-limits under -Wextra. Warnings under GCC's -Wtype-limits is covered in Clang by -Wtautological-type-limit-compare and -Wtautological-unsigned-zero-compare.

Since -Wtautological-type-limit-compare can fire spuriously when a type's size is platform-dependent (as detailed in D41512), I am adding only -Wtautological-unsigned-zero-compare to -Wextra.

I should point out that GCC does not throw warnings on pointless unsigned expression comparisons inside templates while -Wtautological-unsigned-zero-compare does. I figure this is a limitation in GCC's implementation and don't think this is an issue but please feel free to let me know if I am mistaken.

Diff Detail

Event Timeline

eandrews created this revision.Aug 31 2018, 8:51 AM

@lebedev.ri is there a specific reason -Wtautological-unsigned-zero-compare was removed? All the issues I am aware of talks about comparisons with min/max.

@lebedev.ri is there a specific reason -Wtautological-unsigned-zero-compare was removed? All the issues I am aware of talks about comparisons with min/max.

Dunno.
Comparison with zero, i would imagine, has the same problem as comparisons with min/max, since comparisons with min == comparison with zero, for unsigned types.

thakis added a comment.Sep 2 2018, 4:22 PM

We don't match gcc's -Wextra behvior. We generally try to not put a ton of stuff in Wextra that isn't in -Wall. (We also generally don't put a lot of stuff in -Wall that isn't enabled by default.) So I don't think we want this.

Alright. Thanks for the review. I will abandon this patch

eandrews abandoned this revision.Sep 4 2018, 7:05 AM