title: Derived-to-base conversion for incomplete types required by decltype
body: <p>I came across this code snipped involving trailing return types and inheritance.</p>
  
  <p>The following minimal example compiles fine with g++, not with clang</p>
  
  <pre><code>struct Base {};
  
  int foo(Base&amp;) {
      return 42;
  }
  
  struct Derived : public Base {
      auto bar() -&gt; decltype(foo(*this)) {
          return foo(*this);
      }
  };
  
  int main()
  {
      Derived derived;
      derived.bar();  
  
      return 0;
  }
  </code></pre>
  
  <p>However, if we change <code>auto bar() -&gt; decltype(foo(*this))</code> to <code>decltype(auto) bar()</code> (c++14 extension), the code compiles also with clang. Link to godbolt <a href="https://godbolt.org/z/qf_k6X" rel="nofollow noreferrer">https://godbolt.org/z/qf_k6X</a> .</p>
  
  <p>Can anyone explain me</p>
  
  <ul>
  <li>how <code>auto bar() -&gt; decltype(return expression)</code> differs from <code>decltype(auto) bar()</code></li>
  <li>why the behavior between compilers differs</li>
  <li>what the right implementation is?</li>
  </ul>