mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 20:01:31 -05:00
We represent the type of a pack init-capture as auto... with packs from the initializer stuck into PACK_EXPANSION_PARAMETER_PACKS so that expanding it produces the right number of elements. But when partially instantiating the auto..., we were changing PACK_EXPANSION_PARAMETER_PACKS to refer to only the auto itself. Fixed thus. gcc/cp/ChangeLog: PR c++/97938 * cp-tree.h (PACK_EXPANSION_AUTO_P): New. * lambda.c (add_capture): Set it. * pt.c (tsubst_pack_expansion): Handle it. gcc/testsuite/ChangeLog: PR c++/97938 * g++.dg/cpp2a/lambda-pack-init6.C: New test.
28 lines
423 B
C
28 lines
423 B
C
// PR c++/97938
|
|
// { dg-do compile { target c++20 } }
|
|
|
|
template <typename... Args>
|
|
int sink(Args&&... args) { return 2; }
|
|
|
|
auto fwd1(const auto&&... ts1) {
|
|
return
|
|
[...ts1 = ts1] {
|
|
return sink(ts1...);
|
|
}();
|
|
}
|
|
|
|
template <typename T1>
|
|
auto fwd2(const T1& t1) {
|
|
return
|
|
[] (auto&&... ts1) {
|
|
return
|
|
[...ts1 = ts1] {
|
|
return sink(ts1...);
|
|
}();
|
|
}();
|
|
}
|
|
|
|
int main() {
|
|
return fwd1() + fwd2(1);
|
|
}
|