[cfe-dev] null pointer literals, warnings, and fixups

David Blaikie dblaikie at gmail.com
Thu Aug 25 10:35:07 PDT 2011


>
> Even suggesting nullptr in C++11? With things like the bool warning, NULL*
> used in non-pointer contexts, etc already, this seems like a fairly logical
> continuation/generalization of that - or would you say that, even in C++11,
> that it's clear that false is probably not intended as a pointer literal but
> still likely that someone should use 0/NULL/etc rather than nullptr?
>

I suppose the difference (moreso in C++98) is between detecting places where
the user was probably way off (false initing pointers, arithmetic comparison
with NULL, etc) & a legitimate (if questionable) matter of style.

Recommending nullptr in C++11 seems, to me, to tip towards less a matter of
style - even if other null pointers aren't explicitly deprecated, it's
pretty close to that kind of situation.

I'd have to look through more warnings (clangs & gccs) to see if I could
understand/discern some generality about which things should be warnings &
which things shouldn't (hard to tell the latter whether they've been omitted
by design or just not done yet). Though it'd be nice to build a more general
auto-styling tool for things that are clearly outside clang's scope.

[I wonder how easy it would be to implement line length limits & break in
sensible places... seems to be the one LLVM developers most often violate.
Then naming conventions (casing), NULL/0 usage (& null-testing expressions,
as someone else brought up recently), braced single-statement blocks, early
returns, etc... ]

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110825/f7a3da93/attachment.html>


More information about the cfe-dev mailing list