[LLVMbugs] [Bug 21110] New: Stop -Wshadow from catching obviously intended shadowing

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 30 23:04:35 PDT 2014


            Bug ID: 21110
           Summary: Stop -Wshadow from catching obviously intended
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: seth.cantrell at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

-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.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141001/45928f94/attachment.html>

More information about the llvm-bugs mailing list