[LLVMbugs] [Bug 20340] New: false different type error message with templates and using

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 17 04:16:52 PDT 2014


            Bug ID: 20340
           Summary: false different type error message with templates and
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andrea.bressan at jku.at
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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 (){...}


  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;


  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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140717/764443d7/attachment.html>

More information about the llvm-bugs mailing list