<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - non-constexpr recursive variable templates are instanciated wrongly"
   href="https://llvm.org/bugs/show_bug.cgi?id=29033">29033</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>non-constexpr recursive variable templates are instanciated wrongly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>felix.morgner@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16980" name="attach_16980" title="Code generated by clang++ -std=c++14 -Wall -Wextra -pedantic -S">attachment 16980</a> <a href="attachment.cgi?id=16980&action=edit" title="Code generated by clang++ -std=c++14 -Wall -Wextra -pedantic -S">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>