-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
False positive error: pack expansion contains parameter pack '_UTypes' that has a different length (1 vs. 2) from outer parameter packs #61415
Comments
CC @erichkeane |
@llvm/issue-subscribers-c-2b |
@llvm/issue-subscribers-clang-frontend |
(might be a duplicate of #17042) |
I'll need a minimal example here, I got lost on the initial one trying to figure out what is going on inside of Tuple. Also, would be nice to know if perhaps this is just a libc++ bug instead :) |
Ok I will try to reduce it today, so we stop relying on libstc++ headers. |
I think a reduced example exhibiting the same underlying issue is still as discussed at Pack expansion bug?, $ cat test.cc
template<typename, typename> struct Pair;
template<typename...> struct Tuple;
template<typename... Ts> struct A {
template<typename... Us> using B = Tuple<Pair<Ts, Us>...>;
};
template<typename... Ts> struct C {
template<typename... Us> using D = typename A<Ts...>::template B<Us...>;
};
using E = C<int, int>::D<int, int>; $ clang++ -fsyntax-only test.cc
test.cc:4:30: error: pack expansion contains parameter pack 'Us' that has a different length (2 vs. 1) from outer parameter packs
template<typename... Us> using B = Tuple<Pair<Ts, Us>...>;
^~~~~
test.cc:7:68: note: in instantiation of template type alias 'B' requested here
template<typename... Us> using D = typename A<Ts...>::template B<Us...>;
^
test.cc:9:11: note: in instantiation of template class 'C<int, int>' requested here
using E = C<int, int>::D<int, int>;
^
1 error generated. |
Note, I didn't try to reduce my case since @stbergmann posted his own reduced C++ snippet. Apparently it's not a regression in clang, as it seems clang never accepted this code in any version (checking on Compiler Explorer). In practice, given the updates made on libstdc++ side, it makes the just released clang 16 error when using libstdc++ tuples with C++23. |
The problem still happens with clang 17 rc1. |
Note: with gcc 13 now being released, this bug is more likely to be triggered in real life code. Anyone using libstdc++ >= 13 and C++ >= 23 and trying to use maps using std::tuple will trigger this bug. |
Maybe related: #32252 |
It triggers in real life code with clang 17.0.1 and libstdc++ 13 indeed. |
Hi, The original reproducer in the first message of this issue seems to no longer happen with the clang trunk (and is still broken with clang 17, so it's not some hidden clang workaround on libstdc++ side which "fixed" the issue). However the reduced reproducer from @stbergmann here #61415 (comment) is still broken right now with clang trunk. Cheers, |
Did anyone try clang 18.1? |
No, and Compiler explorer doesn't have clang 18 yet. However it works with clang trunk since some months, so there is no reason it shouldn't work with clang 18 (the reproducer from the first message). However it seems the reduced case from @stbergmann in #61415 (comment) is still broken on trunk. |
I think we should close this issue. CC @stbergmann can you confirm if your reduced case is the same as #32252 |
The combination of libstdc++ >= 13, c++ >= 23 and clang 16 has this bug that caused compilation issues on ubuntu: * llvm/llvm-project#61415 This does not cause any compilation errors on fedora because fedora has a patch version higher gcc and libstdc++ version. Seastar recently upgraded to using c++23, so this is why we are seeing this error now.
The combination of libstdc++ >= 13, c++ >= 23 and clang 16 has this bug that caused compilation issues on ubuntu: * llvm/llvm-project#61415 This does not cause any compilation errors on fedora because fedora has a patch version higher gcc and libstdc++ version. Seastar recently upgraded to using c++23, so this is why we are seeing this error now.
Original test case works fine with Clang 18.1. |
…acks (#120380) CheckParameterPacksForExpansion() previously assumed that template arguments don't include PackExpansion types when attempting another pack expansion (i.e. when NumExpansions is present). However, this assumption doesn't hold for type aliases, whose substitution might involve unexpanded packs. This can lead to incorrect diagnostics during substitution because the pack size is not yet determined. To address this, this patch calculates the minimum pack size (ignoring unexpanded PackExpansionTypes) and compares it to the previously expanded size. If the minimum pack size is smaller, then there's still a chance for future substitution to expand it to a correct size, so we don't diagnose it too eagerly. Fixes #61415 Fixes #32252 Fixes #17042
Hi,
This is an issue similar #58452, actually the snippet I posted in this issue is the same. Using libstc++'s 13 tuple implementation is still not possible when using
-std=c++2b
:Godbolt output (https://godbolt.org/z/Meca376M6):
The text was updated successfully, but these errors were encountered: