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

2025-03-08


2984. Value-dependent structured bindings

Section: 13.8.3.4  [temp.dep.constexpr]     Status: open     Submitter: Michael Park     Date: 2025-01-14

Consider:

  struct S { int x; };

  template <S s>
  void f() {
   constexpr auto [x] = s;
   constexpr bool b = (x == 0); // x ought to be value-dependent
  }

The rules in 13.8.3.4 [temp.dep.constexpr] do not seem to cover the case of structured bindings.

Possible resolution (January, 2025) [SUPERSEDED]:

Change in 13.8.3.4 [temp.dep.constexpr] paragraph 2 as follows:

An id-expression is value-dependent if

Possible resolution (February, 2025):

  1. Change in 13.8.3.4 [temp.dep.constexpr] paragraph 2 as follows:

    An id-expression is value-dependent if
    • it is a concept-id and any of its arguments are dependent,
    • it is type-dependent,
    • it is the name of a non-type template parameter,
    • it names a static data member that is a dependent member of the current instantiation and is not initialized in a member-declarator,
    • it names a static member function that is a dependent member of the current instantiation, or
    • it names a potentially-constant variable (7.7 [expr.const]) that is initialized with an expression that is value-dependent. , or
    • it names a structured binding whose structured binding declaration (9.6 [dcl.struct.bind]) has a brace-or-equal-initializer that is value-dependent.
  2. Add after 13.8.3.4 [temp.dep.constexpr] paragraph 6 as follows:

    ... An expression of the form &cast-expression is also value-dependent if evaluating cast-expression as a core constant expression (7.7 [expr.const]) succeeds and the result of the evaluation refers to a templated entity that is an object with static or thread storage duration or a member function.

    A braced-init-list is value-dependent if any element is value-dependent or is a pack expansion.