Clang fails to compile code that uses std::apply on a member variable from a __restrict member function (original) (raw)
| Bugzilla Link | 43066 |
|---|---|
| Version | trunk |
| OS | All |
| CC | @dwblaikie,@DougGregor,@dobbelaj-snps,@ameisen,@zygoloid,@zoecarver |
Extended Description
The following code fails to compile under Clang with '-std=c++2a' and '-std=c++17':
#include
struct foo { const std::tuple v_; constexpr foo (int v) : v_(v) {}
bool operator == (int value) const __restrict {
return std::apply([](auto) {return true;}, v_);
}};
bool test (int v) { return foo{0} == v; }
If the __restrict is removed from the operator ==, it compiles.
This code successfully compiles under GCC and MSVC:
The core errors appear to be:
tuple:1271:44: error: implicit instantiation of undefined template 'std::tuple_size<__restrict std::tuple<int> >'
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
tuple:1686:44: error: non-type template argument is not a constant expression
using _Indices = make_index_sequence<tuple_size_v<decay_t<_Tuple>>>;
tuple:1687:14: error: no matching function for call to '__apply_impl'
return std::__apply_impl(std::forward<_Fn>(__f),