http://llvm.org/bugs/show_bug.cgi?id=20340

            Bug ID: 20340
           Summary: false different type error message with templates and
                    using
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Created attachment 12782
  --> http://llvm.org/bugs/attachment.cgi?id=12782&action=edit
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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to