This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 120c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-08-20


3218. Expanding packs created within a pack expansion

Section: 13.7.4  [temp.variadic]     Status: open     Submitter: Jay Ghiron     Date: 2026-08-16

(From submission #976.)

Consider:

   struct S {};

   int f(auto ... x) {
     int a[] = { [&] {
       auto[...y] = x;
       return y;    // #1
     }()...};       // #2
     return 0;
   }
   int x = f(S());

The use of y at #1 should be ill-formed due to the appearance of an unexpanded pack. The expansion at #2 should not apply to y. Some implementations fail spectacularly.

Possible resolution:

Change in 13.7.4 [temp.variadic] paragraph 8 as follows:

A pack whose name appears within the pattern of a pack expansion is expanded by that pack expansion if unqualified name lookup (6.5.3 [basic.lookup.unqual]) from the point of the pack expansion finds a declaration of that pack. An appearance of the name of a pack is only expanded by the innermost enclosing pack expansion. The pattern of a pack expansion shall name one or more packs that are not expanded by a nested pack expansion; such packs are called unexpanded packs in the pattern. All of the packs expanded by a pack expansion shall have the same number of arguments specified. An appearance of a name of a pack that is not expanded is ill-formed. [Example: ...
  int h(auto) {
    ([](auto ...xs){ xs; }, ...);   // error: unexpanded pack
  }
-- end example]