<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Stop -Wshadow from catching obviously intended shadowing"
   href="http://llvm.org/bugs/show_bug.cgi?id=21110">21110</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Stop -Wshadow from catching obviously intended shadowing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>seth.cantrell@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>-Wshadow ignores (or rather, never notices) shadowing between variables and
lambda captures of those variables, because shadowing is generally reasonable
in such conditions:

    int i = 0;
    for_each(..., [i] (auto &e) {
      // use variable i, no shadowing warning
    });

Of course there are times when the a lambda's captures' shadowing might be
problematic and a warning could be appropriate:

    int i, j;
    [&i = j] { // use i...? }

However ignoring the shadowing by captures is usually the right thing, and it's
a happy accident that this is the current behavior, but there are other
instances where shadowing should be ignored:

    class Foo {
      int bar, baz;

      Foo(int bar, int baz) : bar(bar), baz(baz) {}
    };

Ignoring clearly intended cases of shadowing would reduce the false positive
rate of this warning.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>