<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 26, 2011, at 2:53 PM, David Blaikie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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></blockquote><div><br></div>Committed as r138687, thanks!</div><div><br><blockquote type="cite"><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></blockquote><div><br></div><div>Good point. It seems that we don't need to provide the first note if we know we're providing the second. Looping in Ted to get his opinion.</div><br></div><span class="Apple-tab-span" style="white-space:pre">      </span>- Doug</body></html>