https://llvm.org/bugs/show_bug.cgi?id=28711
Bug ID: 28711 Summary: error: non-type template argument is not a constant expression (GCC compiles, clang doesn't) Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: we...@wsoptics.de CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified 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()>{}); -- 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