title: (GCC bug?) Implicit conversion to a derived class
body: <p>I've encountered a problem with implicit conversion in C++. The following is a minimal example:</p>
  
  <pre><code>struct A {
    virtual void f()=0; // abstract
  };
  
  struct Ad : A {
    virtual void f() {} // not abstract
  };
  
  struct B {
    operator Ad () const { return Ad(); }
  };
  
  void test(A const &amp;lhs) {}
  
  int main()
  {
    B b;
    test(b);
  }
  </code></pre>
  
  <p>What I would like the compiler to do is: convert b to a variable of type Ad (using the conversion defined in B) and pass the result to <em>test</em>. However, the above code does not compile in GCC (with C++11 enabled), the result being <em>Cannot allocate an object of abstract type 'A'</em>.</p>
  
  <p>Some things to note:</p>
  
  <ol>
  <li>Clang compiles this.</li>
  <li>If you make A non-abstract by changing <code>f()=0;</code> to <code>f() {}</code>, the code works just fine.</li>
  <li>The compiler does find the conversion operator (as indicated by 2), but it doesn't do what I'd like it to do.</li>
  </ol>