This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Moved to DR at the October, 2012 meeting.]
In spite of the resolution ofissue 112,the exact relationship between cv-qualifiers and array types is notclear. There does not appear to be a definitive normative statementanswering the question of whether an array with a const-qualifiedelement type is itself const-qualified; the statement in6.9.5 [basic.type.qualifier] paragraph 5,
Cv-qualifiers applied to an array type attach to the underlyingelement type, so the notation “cvT,”whereT is an array type, refers to an array whoseelements are so-qualified. Such array types can be said to bemore (or less) cv-qualified than other types based on thecv-qualification of the underlying element types.
hints at an answer but is hardly decisive. For example, isthe following example well-formed?
template <class T> struct is_const { static const bool value = false; }; template <class T> struct is_const<const T> { static const bool value = true; }; template <class T> void f(T &) { char checker[is_const<T>::value]; } int const arr[1] = {}; int main() { f(arr); }Also, when 7.2.1 [basic.lval] paragraph 4 says,
Class prvalues can have cv-qualified types; non-class prvaluesalways have cv-unqualified types.
does this apply to array rvalues, as it appears? That is,given
struct S { const int arr[10]; };is the array rvalueS().arr an array ofintor an array ofconst int?
(The more general question is, when the Standard refers tonon-class types, should it be considered to include array types?Or perhaps only arrays of non-class types?)
Proposed resolution (December, 2011):
Change 6.9.5 [basic.type.qualifier] paragraph 5 as follows:
...Cv-qualifiers applied to an array type attach to the underlyingelement type, so the notation “cvT,”whereT is an array type, refers to an array whose elements areso-qualified.Such array types can be said to be more (or less)cv-qualified than other types based on the cv-qualification of theunderlying element types.An array type whose elements arecv-qualified is also considered to have the same cv-qualification asits elements. [Example:typedef char CA[5]; typedef const char CC; CC arr1[5] = { 0 }; const CA arr2 = { 0 };The type of botharr1 andarr2 is“array of 5const char,” and the array type isconsidered to beconst-qualified. —endexample]
Change 7.2.1 [basic.lval] paragraph 4 as follows:
Classand array prvalues can have cv-qualified types;non-classother prvalues always havecv-unqualified types. Unless otherwise indicated...