Title
Dynamic const objects
Status
cd3
Section
6.8.4 [basic.type.qualifier]
Submitter
Daniel Krügler

Created on 2011-12-08.00:00:00 last changed 90 months ago

Messages

Date: 2012-10-15.00:00:00

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

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

  1. Change 6.8.4 [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 (Clause 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.

    • A const object is an object of type const T or a non-mutable subobject of such an object.

    • A volatile object is an object of type volatile T, a subobject of such an object, or a mutable subobject of a const volatile object.

    • A const volatile object is an object of type const volatile T, a non-mutable subobject of such an object, a const subobject of a volatile object, or a non-mutable volatile subobject of a const 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.4 [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...
Date: 2011-12-08.00:00:00

The definition of “const object” in 6.8.4 [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.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: + msg4123
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: + msg3693
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-12-08 00:00:00admincreate