CWG Issue 2506 (original) (raw)

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

2025-04-13


2506. Structured bindings and array cv-qualifiers

Section: 9.7 [dcl.struct.bind]Status: CD6Submitter: Barry RevzinDate: 2018-12-11

[Accepted at the February, 2022 meeting.]

According to 9.7 [dcl.struct.bind] paragraph 1,

A structured binding declaration introduces the identifiers v0, v1,v2, ... of the identifier-list as names of structured bindings. Let cv denote the _cv-qualifier_s in the _decl-specifier-seq_and S consist of the _storage-class-specifier_s of the decl-specifier-seq (if any). A cv that includes volatile is deprecated; see D.4 [depr.volatile.type]. First, a variable with a unique name e is introduced. If the assignment-expression in the initializer has array type A and no ref-qualifier is present, e is defined by

attribute-specifier-seqopt S cv A e ;

and each element is copy-initialized or direct-initialized from the corresponding element of the assignment-expression as specified by the form of the initializer.

This means that in an example like

const int arr[1]{}; auto [i] = arr;

i is a reference to const int. Presumably the fact that the array is copied should drop the array's cv-qualification.

Proposed resolution (December, 2021):

Change 9.7 [dcl.struct.bind] paragraph 1 as follows:

If the assignment-expression in the initializer has array type cv1 A and no ref-qualifier is present, e is defined by...