https://llvm.org/bugs/show_bug.cgi?id=29033
Bug ID: 29033 Summary: non-constexpr recursive variable templates are instanciated wrongly Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++14 Assignee: unassignedclangb...@nondot.org Reporter: felix.morg...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16980 --> https://llvm.org/bugs/attachment.cgi?id=16980&action=edit Code generated by clang++ -std=c++14 -Wall -Wextra -pedantic -S The following code: #include <iostream> template<std::size_t N> auto fibo_v{fibo_v<N-1> + fibo_v<N-2>}; template<> auto fibo_v<0>{0}; template<> auto fibo_v<1>{1}; int main() { std::cout << fibo_v<4> << '\n'; } produces 0 as its output. Adding constexpr to the variable declarations resolves this and produces the correct result 3. As far as i can tell, N3651 lifted the restriction on variable templates to be constexpr, thus i would expect the same result with and without constexpr in the declarations. GCC 6.1.1 produces the correct output, regardless of constexpr being in place or not. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs