Surprisingly, unrelated to this whole discussion about nullptr usage, etc, I came across this fixit note that could be improved for C++0x:<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">foo.cpp:6:7: warning: variable 'i' is uninitialized when used here [-Wuninitialized]</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">  foo(i);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      ^</font></div><div><font class="Apple-style-span" face="'courier new', monospace">foo.cpp:5:3: note: variable 'i' is declared here</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">  int* i;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">  ^</font></div><div><font class="Apple-style-span" face="'courier new', monospace">foo.cpp:5:9: note: add initialization to silence this warning</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">  int* i;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">        ^</font></div><div><font class="Apple-style-span" face="'courier new', monospace">         = NULL</font></div>
</div><div><br></div><div>(no color this time - the demo page doesn't do warning flags yet, so I had to copy/paste this from a terminal instead)</div><div><br></div><div>This warning currently suggests NULL if it's defined* otherwise it suggests 0. This patch enhances this to prefer nullptr over either of these if compiling as C++0x, otherwise to fall back to NULL then 0.</div>
<div><br></div><div>Side note: Do we really need that first note if we're providing the second note? I realize in some cases the first note is all we'll get, because there's no initialization we can guess to provide. But in the cases where there is an init suggestion, could we just provide that instead of the "variable '%s' is declared here"?</div>
<div><br></div><div>- David</div><div><br></div><div>* neat stuff, btw - though I wonder how smart that engine is - obviously it's not caring about whether it finds the real stdlib NULL or some user-defined, unrelated NULL (but that's probably ok) - but it does make me wonder how it's keeping track of/representing the current state of the preprocessor so that if I define NULL between one line & the next it somehow gets it right. Oh, I guess it doesn't - if I don't define NULL until after that line it still suggests that I use NULL. Eh, near enough I think.</div>