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

Chandler Carruth chandlerc at google.com
Thu Jun 12 03:49:40 PDT 2014


On Thu, Jun 12, 2014 at 11:40 AM, Stephan Bergmann <sbergman at redhat.com>
wrote:

> On 06/06/2014 11:39 PM, Richard Trieu wrote:
>
>> Author: rtrieu
>> Date: Fri Jun  6 16:39:26 2014
>> New Revision: 210372
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=210372&view=rev
>> Log:
>> Add -Wtautological-undefined-compare and -Wundefined-bool-conversion
>> warnings
>> to detect underfined behavior involving pointers.
>>
>
> Given that code that offends -Wtautological-undefined-compare (by
> checking a reference for null) often also deliberately creates such null
> references, a la
>
>   int & r = *(int*)0;
>
> is there any fundamental reason to not also add a warning for such
> constructs?


Makes sense to me. We should warn for anything which the full power of the
Clang-side constant folding can see a null pointer being bound to a
reference, provided it isn't in dead code (which we already have a
mechanism for).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140612/7f8d297e/attachment.html>


More information about the cfe-commits mailing list