http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57709

            Bug ID: 57709
           Summary: -Wshadow is too strict / has false positives
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jan.kratochvil at redhat dot com
            Target: x86_64-unknown-linux-gnu

class C {
  int both_var;
  void var_and_method() {}
  void m() { int both_var, var_and_method; }
};

FAIL: gcc (GCC) 4.8.2 20130625 (prerelease)
FAIL: gcc (GCC) 4.9.0 20130625 (experimental)
g++ -c -o shadow.o shadow.C -Wshadow -Wno-unused
shadow.C:4:18: warning: declaration of ‘both_var’ shadows a member of 'this'
[-Wshadow]
shadow.C:4:28: warning: declaration of ‘var_and_method’ shadows a member of
'this' [-Wshadow]

clang-3.3-0.4.rc2.fc18.x86_64
clang -c -o shadow.o shadow.C -Wshadow -Wno-unused
shadow.C:4:18: warning: declaration shadows a field of 'C' [-Wshadow]
  void m() { int both_var, var_and_method; }
                 ^
shadow.C:2:7: note: previous declaration is here
  int both_var;
      ^
1 warning generated.

------------------------------------------------------------------------------

clang does no warn on "var_and_method" as variable vs. method are safe, if one
tries to use them inappropriately one gets an error.

It is difficult to enable -Wshadow for existing project as it has many needless
warnings, with clang it is easier and still safe.

Reply via email to