title: return type deduction and function declarations
body: <p>How can I declare a function in a class that uses return type deduction?</p>
  
  <p>This is fine:  </p>
  
  <pre><code>auto foo() {
      return 5;
  }
  </code></pre>
  
  <p>But this does not work:</p>
  
  <pre><code>class Test {
      auto foo();
  };
  auto Test::foo() {
      return 5;
  }
  </code></pre>
  
  <blockquote>
    <p>internal compiler error: in gen_type_die_with_usage, at dwarf2out.c:19486</p>
  </blockquote>
  
  <p>I don't know if it has anything to do with it but I am using QtCreator 3.3.</p>
  
  <p><strong>EDIT</strong>:
  I am using Qt 5.4 and QtCreator 3.3.
  I have added <code>CONFIG   += c++14</code> to the project file.
  By default, I am using GCC 4.8.2 and I guess this is why I get the error (I need <a href="https://stackoverflow.com/questions/19846097/return-type-deduction-for-class-methods-c1y">4.9</a>). However when I use Clang 3.5 (<a href="http://clang.llvm.org/cxx_status.html" rel="nofollow noreferrer">3.4</a> is needed) it says </p>
  
  <blockquote>
    <p>error: 'auto' return without trailing return type; deduced return types are a C++1y extension</p>
  </blockquote>
  
  <p><strong>EDIT2</strong>: This seems to be a bug with Qt and not with GCC. Outside of Qt I can write class functions with return type deductions and it compiles and runs just fine with GCC 4.8.2 and Clang 3.5.0</p>