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

Chandler Carruth chandlerc at google.com
Tue Aug 5 16:22:47 PDT 2014


On Tue, Aug 5, 2014 at 4:20 PM, Nico Weber <thakis at chromium.org> wrote:

> The undefined behavior isn't the check, but the code that preceded it and
> that made someone put in the fix:
>
>   int* a = nullptr;
>   int& ra = *a;  // Undefined! But also harmless in practice.
>
>   if (a == 5) {} // Crash! Better "fix" this by instead writing:
>   if (&a && a == 5) {} // No crash! Except if the compiler rightfully
> optimizes away the &a check.
>
> If you don't have an ubsan bot, then it's possible that your code has
> references to null. That's undefined, but used to be safe in practice – but
> now that clang marks addresses of references as non-null, it isn't
> anymore. Wtautological-undefined-compare catches some of these places.
>

Yea, I'm just pointing out that I can see an argument where its hard to
argue that we shouldn't turn this warning off on code that doesn't care
about tautological comparisons... =/ I don't really have a better idea of
how to organize them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/720c6809/attachment.html>


More information about the cfe-commits mailing list