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

             Bug #: 13729
           Summary: Dependent return type with constant member gives
                    "out-of-line definition differs from the declaration"
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified


template<int n> struct foo { };

template<typename T>
struct curr {
    static const int n = 1;
    foo<n> f();
};

template<typename T>
foo<curr<T>::n> curr<T>::f() {
    return foo<1>();
}

When trying to compile this, I get:

out2.cpp:10:26: error: out-of-line definition of 'curr::f' differs from the
      declaration in the return type
foo<curr<T>::n> curr<T>::f() {
                         ^
out2.cpp:6:9: note: previous declaration is here
        foo<n> f();
               ^
1 error generated.

The annoying bit is that you cannot easily work around this. Trying to change
the declaration of f() to:

foo<curr<T>::n> f();

does not help. The error remains, although the return type is *exactly* the
same.

This may be related to bug #11381, but using a type instead of constant does
not give this problem. For example:


template<typename T> struct foo { };

template<typename T>
struct curr {
    typedef int type;
    foo<type> f();
};

template<typename T>
foo<typename curr<T>::type> curr<T>::f() {
    return foo<int>();
}

This compiles without problems.

All of this is using:

Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.1.0
Thread model: posix

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- 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