title: Why does the compiler warn about shadowing a member in initalization lists?
body: <p>Take a constructor parameter with the same identifier as the data member it's initializing.  If the two are used inside an initialization list, it would be considered safe, and "shadowing" would not occur.  </p>
  
  <p>However, take the following example:  </p>
  
  <pre><code>struct A{
    A(int a, int b);
    int a, b;
  };
  
  A::A(int a, int b)
  : a(a)
  , b(b)
  {}
  
  int main(){}
  </code></pre>
  
  <p><strong>warnings seen with g++:</strong>  </p>
  
  <pre><code>g++ -Wshadow --std=c++1z -o main main.cpp 
  main.cpp: In constructor ‘A::A(int, int)’:
  main.cpp:8:18: warning: declaration of ‘b’ shadows a member of ‘A’ [-Wshadow]
   A::A(int a, int b)
                    ^
  main.cpp:4:10: note: shadowed declaration is here
     int a, b;
            ^
  main.cpp:8:18: warning: declaration of ‘a’ shadows a member of ‘A’ [-Wshadow]
   A::A(int a, int b)
                    ^
  main.cpp:4:7: note: shadowed declaration is here
     int a, b;
  </code></pre>
  
  <p><strong>warnings seen with clang:</strong>  </p>
  
  <pre><code>clang++ -Wshadow --std=c++1z -o main t.cpp
  main.cpp:8:10: warning: declaration shadows a field of 'A' [-Wshadow]
  A::A(int a, int b)
           ^
  main.cpp:4:7: note: previous declaration is here
    int a, b;
        ^
  main.cpp:8:17: warning: declaration shadows a field of 'A' [-Wshadow]
  A::A(int a, int b)
                  ^
  main.cpp:4:10: note: previous declaration is here
    int a, b;
  </code></pre>
  
  <p>I'm not doing anything to the data members in the body of the constructor-- so why am I getting these warnings?  </p>
  
  <p>I'd like to leave the warning flag enabled to catch legitimate mishaps, but these particular cases are causing too much false noise.  Is there validity in these warnings?</p>