<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 15, 2014, at 19:01 , David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Mar 14, 2014 at 7:05 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br><blockquote type="cite">Quentin,<br><br>Clang does not have a warning for uninitialized fields in class methods.<br>I've looked before to add a warning to flag any unused fields at the end of<br>the a constructor.  However, there were good reasons to have uninitialized<br>fields, such as having an Init() method later that initializes the fields,<br>or a guard variable to protect against uninitialized use.  Also,<br>-Wuninitialized typically warns on the use of an uninitialized variable, not<br>the mere presence of one.<br><br>The other idea is to do cross method analysis, either using the control flow<br>of a program to determine which methods are used in which order, or testing<br>methods against constructors.  Such an analysis would likely be too<br>expensive, and would be more suited for static analysis.<br></blockquote><br>We already have at least one cross-method analysis which could<br>actually be used as the basis for the warning under discussion here:<br><br>-Wunused-member-variable. This warning only fires if there are no<br>friends and a private member in a situation where all member functions<br>are defined in one translation unit.  So we could use this to show<br>that there's no initialization of the variable anywhere, but there are<br>uses of it. (essentially the same as -Wunused-member-variable, except<br>allow reads as well)<br></div></blockquote></div><br><div>The analyzer also catches the particular case in your stripped-down test file, and should do so on real code as long as it's all visible in one translation unit. It'd be a lot harder to make this a cross-TU analysis, of course.</div><div><br></div><div>Jordan</div></body></html>