<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 --- - error: non-type template argument is not a constant expression (GCC compiles, clang doesn't)"
   href="https://llvm.org/bugs/show_bug.cgi?id=28711">28711</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>error: non-type template argument is not a constant expression (GCC compiles, clang doesn't)
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>weiss@wsoptics.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I believe that the following code is valid C++14 and should compile.  GCC 5.4.0
does compile it without warnings:

-----------------------
#include <array>
#include <cstddef>
#include <utility>

namespace detail {
    namespace detail {
        template<typename R, typename F, typename A, std::size_t... index>
            constexpr decltype(auto) func_apply_impl(F && f, A && a,
std::index_sequence<index...>)
            {
                return R{f(std::forward<A>(a)[index])...};
            }
    }
    //! Take an object a of type A that has size() and operator[] and return
R{f(a[0]), ..., f(a[a.size()-1])}
    template<typename R, typename F, typename A>
        constexpr decltype(auto) func_apply(F && f, A && a)
        {
            return detail::func_apply_impl<R>(std::forward<F>(f),
std::forward<A>(a), std::make_index_sequence<a.size()>{});
        }

}

template<typename T, std::size_t N> constexpr auto operator*(T const t,
std::array<T, N> const & rhs) { return detail::func_apply<std::array<T, N>>([t]
(const auto r) { return t * r; }, rhs); }

int main()
{
    const std::array<int, 3> a{1, 2, 3};

    const auto b = 2 * a;

    return 0;
}
----------------------

It might be related to 28385, but it behaves the same with both --std=c++14 and
--std=c++1z


clang 3.8.1 gives:
/tmp/z.cpp:17:103: error: non-type template argument is not a constant
expression
        return detail::func_apply_impl<R>(std::forward<F>(f),
std::forward<A>(a), std::make_index_sequence<a.size()>{});</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>