<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Chandler, Richard,<div><br></div><div>I just noticed Chandler's commit.  I think this is a needed warning, but I'm a little concerned that the logic here is redundant.  Clang has a generic -Wuninitialized dataflow analysis, and it seems like cases like this should be caught there.  Doing an extra check seems like redundant work.  Was there a particular motivation to do the check this way?</div><div><br></div><div>I'm also mildly concerned that variable initialization is essentially a flow-sensitive property.  While contrived, the following case would falsely trigger warning from the logic added in r128376:</div><div><br></div><div>  int x = (x = 1, x);</div><div><br></div><div>While this is obviously contrived, my point is that reasoning about such cases doesn't require any explicit logic in the dataflow analysis; it just falls out.  While the dataflow analysis doesn't handle C++ initializers (yet) in constructors, when it does it will be able to handle control-flow dependencies between initializers as well.  My feeling is that since we already have a dataflow analysis for uninitialized variables, I'd rather focus on making that better than adding ad hoc checks for corner cases.</div><div><br></div><div>What do you guys think?</div><div><br></div><div>Ted</div><div><br><div><div>On Mar 27, 2011, at 2:53 AM, Chandler Carruth wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks Richard. I've committed this after making a few tweaks in r128376.<div><br></div><div>For reference, the tweaks I made were:</div><div>- Moved under -Wuninitialized and grouped the warning appropriately for that</div>
<div>- Slightly tweaked the wording to flow better and match existing uninitialized warnings' wording</div><div>- Only underline the identifier rather than the entire declaration. I think this looks a bit better and should avoid issues in cases like:</div>
<div><br></div><div>int x, y = y + 2;</div><div><br></div><div>- Some formatting tweaks here and there.</div><div><br><div class="gmail_quote">On Tue, Mar 22, 2011 at 6:43 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Add a warning on variable initialization which references its own value.  Non-evaluated expressions, such as address of or size of operations, are not warned on.
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote></div><br></div></body></html>