Title
Expanding packs created within a pack expansion
Status
open
Section
13.7.4 [temp.variadic]
Submitter
Jay Ghiron

Created on 2026-08-16.00:00:00 last changed 5 days ago

Messages

Date: 2026-08-16.10:44:35

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]
Date: 2026-08-16.00:00:00

(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.

History
Date User Action Args
2026-08-16 10:40:15adminsetmessages: + msg8648
2026-08-16 00:00:00admincreate