title: Derived exception class not caught
body: <p>Starting to use the googletest ASSERT_THROW clause, it seems that 'sometimes' the base type of the thrown exception is handled.  I reduced the relevant code section to this:</p>
  
  <pre><code>// myexception.h
  struct myexception : public std::logic_error {
     myexception(const char* what):std::logic_error(what){}
  };
  void throwMy();
  
  // myexception.cpp
  void throwMy(){ throw myexception(NULL); }
  </code></pre>
  
  <p>This is my test code:</p>
  
  <pre><code>//
  void localThrowMy(){ throw myexception(""); }
  
  // test code, based upon the ASSERT_THROW macro
  try {
    throwMy();        // outputs "logic_error"
    //localThrowMy(); // would output "what I expected"
  }
  catch( myexception &amp; ) { cout &lt;&lt; "what I expected"; }
  catch( std::logic_error &amp; ) { cout &lt;&lt; "logic_error"; } // my addition
  catch(...) { cout &lt;&lt; "mmmh."; }
  </code></pre>
  
  <p>The strange thing is: if I declare the <code>throwMy</code> function in the same compilation unit as the test code, "what I expected" is output.  If it's in another unit, the test outputs "logic_error.".</p>
  
  <ul>
  <li>g++ --version: (Debian 4.4.5-8) 4.4.5</li>
  <li>ld --version: (GNU Binutils for Debian) 2.20.1-system.20100303</li>
  </ul>
  
  <p>Is this code correct?  Could the linker be in error here?</p>