[cfe-dev] -Wtautological-constant-compare issues

Vedant Kumar via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 19 15:16:47 PST 2017


Hi,

> On Dec 19, 2017, at 3:02 PM, Shoaib Meenai via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hi all (CC some people who have been involved in this discussion already and Hans for clang 6 release discussion),
>  
> -Wtautological-constant-compare was introduced in r315614 to diagnose tautological comparisons against a type's maximum and minimum bounds. However, this warning can fire spuriously when a type's size is platform-dependent. For example, libc++ has some generic code for which the warning fires on platforms where int and long have the same size;

I think our kernel team is planning on disabling -Wtautological-constant-compare for this exact reason. I've CC'd Alex, who may know more about any issues with this diagnostic w.r.t Apple projects. If the false positive really is widespread, I'd be supportive of disabling it by default or in -Wall.

vedant


> see https://reviews.llvm.org/D39149 <https://reviews.llvm.org/D39149> for my initial attempt to work around the warning, and then https://reviews.llvm.org/D41368 <https://reviews.llvm.org/D41368>, which just silences the warning where it's problematic.
>  
> Unfortunately, this appears to be a pretty widespread problem. For example, Petr Hosek reported in https://reviews.llvm.org/D39462 <https://reviews.llvm.org/D39462> that he had to globally disable the warning when they rolled out a newer clang. Roman attempted to address this problem by having the warning take type size differences into account in https://reviews.llvm.org/D39462 <https://reviews.llvm.org/D39462>, but that's tricky to implement and hit some implementation roadblocks.
>  
> I think shipping the warning in its current state in clang 6 is going to be problematic, because there are going to be many instances of generic code running into spurious warnings. At the very least, I think the warning as-is shouldn't be part of -Wall. What are other people's thoughts on this issue?
>  
> Thanks,
> Shoaib
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171219/4d142304/attachment.html>


More information about the cfe-dev mailing list