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

Stephan Bergmann sbergman at redhat.com
Thu Jun 12 03:40:57 PDT 2014


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?  It could help in cleaning up code to be 
-Wtautological-undefined-compare--free (and for LibreOffice I managed 
with a local Clang plugin for now, 
<http://cgit.freedesktop.org/libreoffice/core/commit/?id=90d8b417cab85dc911fe6b69ddf6cca0679abd04> 
"New loplugin:derefnullptr (all violations already fixed)").

Stephan




More information about the cfe-commits mailing list