clang trunk rejects incorrect pack indexing expression
mk-huawei opened this issue · 0 comments
mk-huawei commented
Commit 87f1b5e introduced the usage of pack indexing on supported compilers (currently the only one is clang trunk, to be 19).
A reproducer: https://godbolt.org/z/Y8r9aq7z8 (with the fix and the buggy line commented)
The expression (used in __nth_pack_element_t::operator()
)
return (static_cast<_Ts &&>(__ts)...[_Np]);
seems to be invalid.
IMO, the correct usage is:
return static_cast<_Ts...[_Np] &&>(__ts...[_Np]);
Cf. https://en.cppreference.com/w/cpp/language/pack_indexing. It states:
https://en.cppreference.com/w/cpp/language/pack_indexing
with an example:
template <[std::size_t](http://en.cppreference.com/w/cpp/types/size_t) I, typename... Args>
constexpr decltype(auto) get(Args&&... args) noexcept
{
return [std::forward](http://en.cppreference.com/w/cpp/utility/forward)<Args>(args)...[I]; // error
// use 'std::forward<Args...[I]>(args...[I])' instead
}