title: Covariant return type is not recognized
body: <p>For some reason, up-to-date versions of both GCC and clang do not recognize return type covariance in this particular scenario. The error message is misleading: </p>
  
  <pre><code>error: return type of virtual function 'foo' is not covariant with the return
       type of the function it overrides ('derived *' is not derived from 'base *')
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>class base
  {
  private:
    virtual base * foo() = 0;
  };
  
  template&lt; class T &gt;
  class foo_default_impl : public virtual base
  {
  private:
    T * foo() override { return nullptr; }
  };
  
  class derived : public virtual base, private foo_default_impl&lt; derived &gt;
  {
  };
  
  int main() {
    derived d{}; // error: return type of virtual function 'foo' is not covariant with the return type of the function it overrides ('derived *' is not derived from 'base *')
    return 0;
  }
  </code></pre>