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

2024-12-19


1428. Dynamic const objects

Section: 6.8.5  [basic.type.qualifier]     Status: CD3     Submitter: Daniel Krügler     Date: 2011-12-08

[Moved to DR at the October, 2012 meeting.]

The definition of “const object” in 6.8.5 [basic.type.qualifier] paragraph 1 is:

The presence of a const specifier in a decl-specifier-seq declares an object of const-qualified object type; such object is called a const object.

Because the type of an object created by a new-expression is given by a type-id or new-type-id rather than with a decl-specifier-seq, this definition gives the false impression that objects of dynamic storage duration cannot be const objects. The wording should be adjusted to make it clear that they can.

Proposed resolution (February, 2012):

  1. Change 6.8.5 [basic.type.qualifier] paragraph 1 as follows:

  2. The term object type (6.7.2 [intro.object]) includes the cv-qualifiers specified in the decl-specifier-seq (9.2 [dcl.spec]), declarator ( 9.3 [dcl.decl]), type-id (9.3.2 [dcl.name]), or new-type-id (7.6.2.8 [expr.new]) when the object is created. The presence of a const specifier in a decl-specifier-seq declares an object of const-qualified object type; such object is called a const object. The presence of a volatile specifier in a decl-specifier-seq declares an object of volatile-qualified object type; such object is called a volatile object. The presence of both cv-qualifiers in a decl-specifier-seq declares an object of const-volatile-qualified object type; such object is called a const volatile object.

    The cv-qualified or cv-unqualified versions of a type are distinct types; however, they shall have the same representation and alignment requirements (6.8 [basic.types]).51

  3. Change 6.8.5 [basic.type.qualifier] paragraph 3 as follows:

  4. Each non-static, non-mutable, non-reference data member of a const-qualified class object is const-qualified, each non-static, non-reference data member of a volatile-qualified class object is volatile-qualified and similarly for members of a const-volatile class. See 9.3.4.6 [dcl.fct] and _N4868_.11.4.3.2 [class.this] regarding function types...