<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - false different type error message with templates and using"
   href="http://llvm.org/bugs/show_bug.cgi?id=20340">20340</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>false different type error message with templates and using
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrea.bressan@jku.at
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12782" name="attach_12782" title="test case">attachment 12782</a> <a href="attachment.cgi?id=12782&action=edit" title="test case">[details]</a></span>
test case

clang wrongly reports that the return type of the out-of-line definition of a
member function differs from the declared one.

I tested the attached test code with clang 3.3 and 5.0, g++, icc and vc++.
Only clang reports the following error:

not_same_return.cpp:32:41: error: out-of-line definition of 'Derived::f'
differs from the declaration in the return type
typename BaseClass<T>::Type Derived<T>::f ()
                                        ^
not_same_return.cpp:19:18: note: previous declaration is here
    virtual Type f ();
                 ^
1 error generated.

I triede the two following workarounds:

1: Changing 

  template <typename T>
  typename BaseClass<T>::Type Derived<T>::f (){...}

  to

  template <typename T>
  typename Derived<T>::Type Derived<T>::f (){...}

  makes compilation with clang succeed and that with g++ fail.

2: Replacing 

  using BaseClass<T>::Type;

  with 

  typedef BaseClass<T>::Type Type;

  in the derived class makes both clang and g++ compile
  (I cannot test with icc and vc++ at the moment)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>