New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang's error on non-pack parameter of alias template in a dependent type #84220
Comments
@llvm/issue-subscribers-clang-frontend Author: Jonathan Poelen (jonathanpoelen)
It seems that clang does not consider `sizeof...(xs)` to be a dependent expression when the call to foo is made with a known number of arguments. The expression must absolutely contain `xs...`.
The following code compiles with gcc, but not clang (https://godbolt.org/z/TYzvjTePT): template<int>
struct foo_impl {
template<class>
using f = int;
};
template<class... xs> constexpr int sizeof_pack = sizeof...(xs);
template<class... xs>
using foo = typename foo_impl< // error: pack expansion used as argument for non-pack parameter of alias template
sizeof...(xs) // does not work
// sizeof_pack<xs...> // ok
>::template f<xs...>; // f is dependent on xs
template<class... xs>
using test = list<foo<xs>...>;
// template<class... xs>
// using test = foo<xs...>; // ok with pack...
test<int> a; // ko |
Not sure who is correct: https://godbolt.org/z/6fM5do836 clang/MSVC reject |
Maybe this is cwg1430 Similar gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59701 Not totally sure. |
While canonicalizing the RHS of
... which I suppose we reject per #1430. But I don't think we should: at this point, |
The issue arises in |
…pandedSize There has been an optimization for SizeOfPackExprs since c5452ed, in which we overlooked a case where the template arguments were not yet formed into a PackExpansionType at the token annotation stage. This led to a problem in that a template involving such expressions may lose its nature of being dependent, causing some false-positive diagnostics. Fixes llvm#84220
…pandedSize (#87768) There has been an optimization for `SizeOfPackExprs` since c5452ed, in which we overlooked a case where the template arguments were not yet formed into a `PackExpansionType` at the token annotation stage. This led to a problem in that a template involving such expressions may lose its nature of being dependent, causing some false-positive diagnostics. Fixes #84220
It seems that clang does not consider
sizeof...(xs)
to be a dependent expression when the call to foo is made with a known number of arguments. The expression must absolutely containxs...
.The following code compiles with gcc, but not clang (https://godbolt.org/z/TYzvjTePT):
The text was updated successfully, but these errors were encountered: