<div dir="ltr">On Wed, Oct 9, 2013 at 2:53 PM, Arthur O'Dwyer <span dir="ltr"><<a href="mailto:arthur.j.odwyer@gmail.com" target="_blank">arthur.j.odwyer@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Well, I do think that you should run this diagnostic over a few real<br>

codebases</blockquote><div>Already done.  My comments with the patch reflect the results of running this warning over Google code.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 (libc++? :)) and see whether it produces any false<br>
positives, first.</blockquote><div>False positives only found in template instantiations.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 I suspect there won't be any cases in which the<br>
diagnostic is produced on code that an impartial observer wouldn't<br>
consider inelegant.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Remember, the goal is to catch bugs involving accidental infinite<br>
recursion (due to human confusion with name lookup, overloading,<br>
template instantiation, or parameter pack expansion). If we silence<br>
the diagnostics on templates, then we really limit the usefulness of<br>
this diagnostic.<br></blockquote><div>We also want to limit the number of false positives.  If too many false positives trigger this, users will just disable the warning. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
Can you give some examples of real-world code </blockquote><div> (A) where this diagnostic found bugs in non-template code,</div><div>namespace bar { void foo(); }</div><div>void foo() { return foo(); }  // should be bar::foo();</div>
<div><br></div><div>class A {</div><div>  bool operator==(const A& other);</div><div>  bool operator!=(const A& other) { return *this != other; } // should be !(*this == other)</div><div>};</div><div><br></div><div>
struct Value { int num; };</div><div>struct Wrapper {</div><div>  int num() { return num(); }  // should be V.num;</div><div>  Value V;</div><div>};</div><div><br></div><div><br></div><div> (B) where this diagnostic gave false positives on non-template code,</div>
<div>Nope, didn't find any.</div><div><br></div><div> (C) where this diagnostic gave false positives on template code, and</div><div><div>// Same example as before.</div><div>template <int value></div><div>int sum() {</div>
<div>  return value + sum<value/2>;</div><div>}</div><div><br></div><div>template<></div><div>int sum<1>() { return 1; }</div><div><br></div><div>template<int x, int y></div><div>int calculate_value() {</div>
<div>  if (x != y)</div><div>    return sum<x - y>();</div><div>  else</div><div>    return 0;</div><div>}</div><div><br></div><div>int value = calculate_value<1,1>();</div></div><div><br></div><div>template<int First, int Last></div>
<div>void DoStuff() {</div><div>  if (First + 1 == Last) {</div><div>    DoSomethingHere();  // This gets removed during <0, 0> instantiation in the CFG, I think.</div><div>  } else {</div><div>    DoStuff<First, (First + Last)/2>();</div>
<div>    DoStuff<(First + Last)/2, Last>()</div><div>  }</div><div>}</div><div>DoStuff<0, 1>()</div><div><br></div><div> (D) where this diagnostic found bugs in template code?</div><div><div>struct Value { int num; };</div>
<div>template<typename T></div><div>struct Wrapper {</div><div>  int num() { return num(); }  // should be V.num;</div><div>  T V;</div><div>};</div></div><div>Wrapper<Value> Foo;</div><div><br></div></div></div>
</div>