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

2024-12-06


811. Unclear implications of const-qualification

Section: 9.2.9.2  [dcl.type.cv]     Status: CD2     Submitter: UK     Date: 3 March, 2009

N2800 comment UK 89

[Voted into WP at March, 2010 meeting.]

The normative text in 9.2.9.2 [dcl.type.cv] paragraph 2 reads,

An object declared in namespace scope with a const-qualified type has internal linkage unless it is explicitly declared extern or unless it was previously declared to have external linkage. A variable of non-volatile const-qualified integral or enumeration type initialized by an integral constant expression can be used in integral constant expressions (7.7 [expr.const]).

These two sentences parallel the specifications of 9.2.2 [dcl.stc] paragraph 7 and 7.7 [expr.const]. However, the passages are not identical, leading to questions about whether the meanings are the same.

Proposed resolution (October, 2009):

Change 9.2.9.2 [dcl.type.cv] paragraph 2 as follows:

An object declared in namespace scope with a const-qualified type has internal linkage unless it is explicitly declared extern or unless it was previously declared to have external linkage. A variable of non-volatile const-qualified integral or enumeration type initialized by an integral constant expression can be used in integral constant expressions (7.7 [expr.const]). [Note: Declaring a variable const can affect its linkage (9.2.2 [dcl.stc]) and its usability in constant expressions (7.7 [expr.const]). As as described in 9.4 [dcl.init], the definition of an object or subobject of const-qualified type must specify an initializer or be subject to default-initialization. —end note]