[llvm-bugs] [Bug 27851] New: Non-type parameter link failure in a template function with a dependent template parameter

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 24 01:01:13 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27851

            Bug ID: 27851
           Summary: Non-type parameter link failure in a template function
                    with a dependent template parameter
           Product: clang
           Version: 3.8
          Hardware: PC
               URL: http://coliru.stacked-crooked.com/a/76dbf47d66e9ba0e
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kirshamir at yahoo.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code:

---

#include <iostream>

using namespace std;

template <class T, T v> struct foo{
    static constexpr T val = v;
};

template <class T, T v1, T v2> void isSame4(foo<T, v1> f1, foo<T, v2> f2) {
    cout << "val1: " << f1.val << ", val2: " << f2.val << " are NOT the same"
<< endl;
}

template <class T, T v> void isSame4(foo<T, v> f1, foo<T, v> f2) {
    cout << "val1: " << f1.val << ", val2: " << f2.val << " are the same" <<
endl;
}

int global1 = 3;

int main() {
    isSame4(foo<int, 1>(), foo<int, 1>()); // ok
    isSame4(foo<int*, &global1>(), foo<int*, &global1>()); // error
}

---

Linker error:
undefined reference to `foo<int*, &global1>::val'

(Same, compiles well on g++ 6.1.0).

Related (?):
#15858: https://llvm.org/bugs/show_bug.cgi?id=15858

-- 
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/20160524/230ca533/attachment.html>


More information about the llvm-bugs mailing list