title: What is this? catching polymorphic type X by value [-Wcatch-value=]
body: <p>Does anyone know what the following compilation <code>warning: catching polymorphic type ‘class std::out_of_range’ by value [-Wcatch-value=]</code> warning means and how to correct it?  I copied this code block literally out of Stroustrup's C++ 4th Edition.  Thank you</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;list&gt;
  using std::vector;
  using std::list;
  using std::cout;
  
  template &lt;typename T&gt;
  class Vec : public vector&lt;T&gt; {
   public:
    using vector&lt;T&gt;::vector;  // constructor
  
    T&amp; operator[](int i) { return vector&lt;T&gt;::at(i); }
    const T&amp; operator[](int i) const { return vector&lt;T&gt;::at(i); }
  };
  
  int main(int argc, char* argv[]) {
    vector&lt;int&gt; v0 = {0, 1, 2};
    Vec&lt;int&gt; v1 = {0, 1, 2};
  
    cout &lt;&lt; v0[v0.size()] &lt;&lt; '\n';  // no error
  
    try {
      cout &lt;&lt; v1[v1.size()];  // out of range
    } catch (std::out_of_range) {
      cout &lt;&lt; "tried out of range" &lt;&lt; '\n';
    }
  
    return 0;
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>$ g++ -Wall -pedantic -std=c++11 test69.cc &amp;&amp; ./a.out
  test69.cc: In function ‘int main(int, char**)’:
  test69.cc:32:17: warning: catching polymorphic type ‘class std::out_of_range’ by value [-Wcatch-value=]
     } catch (std::out_of_range) {
                   ^~~~~~~~~~~~
  0
  tried out of range
  </code></pre>