[llvm-bugs] [Bug 29033] New: non-constexpr recursive variable templates are instanciated wrongly
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 18 01:44:24 PDT 2016
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: unassignedclangbugs at nondot.org
Reporter: felix.morgner at gmail.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160818/db712b8f/attachment.html>
More information about the llvm-bugs
mailing list