title: Why is GCC warning me about a useless cast when using an inherited constructor?
body: <p>Consider the following C++ code:</p>
  
  <pre><code>#include &lt;string&gt;
  
  struct A {
      A(const std::string&amp; s): s(s) {}
      std::string s;
  };
  
  struct B: A {
      using A::A;
  };
  
  int main() {
      B b("test");
  }
  </code></pre>
  
  <p>When I compile it via GCC 6.2.1 with the <code>-Wuseless-cast</code> parameter</p>
  
  <pre><code>g++ -std=c++14 -Wuseless-cast test.cpp -o test
  </code></pre>
  
  <p>it emits the following warning:</p>
  
  <pre><code>test.cpp: In constructor ‘B::B(const string&amp;)’:
  test.cpp:9:14: warning: useless cast to type ‘const string&amp; {aka const std::__cxx11::basic_string&lt;char&gt;&amp;}’ [-Wuseless-cast]
      using A::A;
               ^
  test.cpp: In function ‘int main()’:
  test.cpp:13:15: note: synthesized method ‘B::B(const string&amp;)’ first required here
      B b("test");
                ^
  </code></pre>
  
  <p>However, when I change the definition of <code>B</code> to</p>
  
  <pre><code>struct B: A {
      B(const std::string&amp; s): A(s) {}
  };
  </code></pre>
  
  <p>the warning goes away.</p>
  
  <p>Questions:</p>
  
  <ul>
  <li>Why is the warning emitted?</li>
  <li>Why does specifying a constructor for <code>B</code> instead of inheriting it from <code>A</code> fixes the warning?</li>
  </ul>