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

            Bug ID: 20156
           Summary: Variable templates generate compiler warnings and
                    linking errors
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++1y
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The code below compiled with Clang 3.4 using `-std=c++1y -Wall -Wextra
-pedantic -O3` produces the following warning: variable 'M_PI<int>' has
internal linkage but is not defined [-Wundefined-internal]

#include <iostream>

template <typename T>
constexpr T M_PI = T(3.1415926535897932);

template <typename T>
constexpr T CalcCircumference(T d)
{
    return d * M_PI<T>;
}

int main()
{
    std::cout << CalcCircumference(42.0f);
}


Another example here:

template <typename T> T var = 0;
template <typename T> T func() { return var<T>; }
int main() { return func<int>(); }

$ clang++ test2.cc -o test2 -std=c++1y -pedantic -Wall
/tmp/test2-736968.o:test2.cc:function int func(): error: undefined reference to
'var'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

-- 
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