r210372 - Add -Wtautological-undefined-compare and -Wundefined-bool-conversion warnings

Nico Weber thakis at chromium.org
Tue Aug 5 16:30:56 PDT 2014


On Tue, Aug 5, 2014 at 4:24 PM, Chandler Carruth <chandlerc at google.com>
wrote:

>
> On Tue, Aug 5, 2014 at 4:22 PM, Reid Kleckner <rnk at google.com> wrote:
>
>> IMO there is a big difference.  All compilers have always returned true
>> for unsigned >= 0, but other compilers may return true for &reference ==
>> nullptr.
>>
>> So, we can ignore the unsigned >= 0 warning so long as we are reasonably
>> confident in past test coverage.
>>
>> However, with the &reference == nullptr behavior change, we don't have
>> that confidence.  Therefore it is more severe.
>>
>
> FWIW, I think this might be a good reason to default the warning to on,
> but it still seems like a somewhat tenuous argument for
> '-Wno-tautological-compare' to leave this warning enabled...
>

The argument is:
1. Wtautological-compare used to warn on relatively harmless things. This
warning has been around in older clang releases.
2. People disable it for some of their code.
3. clang later adds an optimization to remove null-comparisons of addresses
of references. This is standards-conforming, but it might break some
existing code. As mitigation, it adds Wtautological-undefined-compare (at
least that's what I thought the motivation was). This is new in 3.5.
4. But due to 2, people might not see it and their code breaks needlessly
with 3.5.

If the warning was just called (say) Wnull-reference and if it was in its
own warning group, this wouldn't happen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/e4c54962/attachment.html>


More information about the cfe-commits mailing list