- Title
- Incorrect description of variables that can be initialized
- Status
- c++11
- Section
- 9.5 [dcl.init]
- Submitter
- comp.std.c++
Created on 2007-01-30.00:00:00 last changed 151 months ago
Messages
Date: 2010-08-23.00:00:00
[Voted into WP at August, 2010 meeting.]
Date: 2010-02-15.00:00:00
Proposed resolution (February, 2010): Change 9.5 [dcl.init] paragraph 2 as follows:
Automatic, register, thread_local, static, and
namespace-scoped external variables can be initialized by
Except for objects declared with the constexpr
specifier, for which see 9.2.6 [dcl.constexpr], an
initializer in the definition of a variable can consist
of arbitrary expressions involving literals and previously
declared variables and functions, regardless of the
variable's storage duration. [Example:...
Date: 2008-09-15.00:00:00
Notes from the September, 2008 meeting: The existing wording is intended to exclude block-scope
extern declarations but to allow initializers in all
other forms of variable declarations. The best way to phrase
that is probably to say that all variable definitions (except for
function parameters, where the initializer syntax is used for
default arguments) can have arbitrary expressions as
initializers, regardless of storage duration.
Date: 2008-06-15.00:00:00
Proposed resolution (June, 2008): Change 9.5 [dcl.init] paragraph 2 as follows:
Automatic, register, static, and external variables of namespace scope
Variables of automatic, thread, and static storage duration can
be initialized by arbitrary expressions involving literals and
previously declared variables and functions...
Date: 2007-04-15.00:00:00
Notes from the April, 2007 meeting: This sentence is poorly worded, but the analysis given in
the issue description is incorrect. The intent is simply that
the storage class of a variable places no restrictions on the
kind of expression that can be used to initialize it (in contrast
to C, where variables of static storage duration can only be
initialized by constant expressions).
Date: 2007-01-30.00:00:00
9.5 [dcl.init] paragraph 2 reads, Both “automatic” and “static” are used to
describe storage durations, “register” is
a storage class specifier which indicates the object has
automatic storage duration, “external”
describes linkage, and “namespace scope” is a kind
of scope. Automatic, register, static and external, together
with namespace scope, are used to restrict the
“variables.” Register objects are only a sub-set of automatic objects and thus
the word “register” is redundant and should be elided. If
register objects are to be emphasized, they should be mentioned like
“Automatic (including register)...” Variables having namespace scope can never be automatic; they can
only be static, with either external or internal linkage. Therefore,
there are in fact no “automatic variables of namespace
scope,” and the “static” in “static variables
of namespace scope” is useless. In fact, automatic and static variables already compose all
variables with either external linkage or not, and thus the
“external” becomes redundant, too, and the quoted sentence
seems to mean that all variables of namespace scope can be initialized
by arbitrary expressions. But this is not true because not all
internal variables of namespace scope can. Therefore, the restrictive
“external” is really necessary, not redundant. As a result, the erroneous restrictive “automatic, register,
static” should be removed and the quoted sentence may be changed
to:
Automatic, register, static, and external variables of namespace scope
can be initialized by arbitrary expressions involving literals and
previously declared variables and functions.
External variables of namespace scope can be initialized by arbitrary
expressions involving literals and previously declared variables and
functions.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
| 2011-04-10 00:00:00 | admin | set | status: wp -> fdis |
| 2010-11-29 00:00:00 | admin | set | status: dr -> wp |
| 2010-08-23 00:00:00 | admin | set | messages: + msg2915 |
| 2010-08-23 00:00:00 | admin | set | status: ready -> dr |
| 2010-03-29 00:00:00 | admin | set | status: review -> ready |
| 2010-02-16 00:00:00 | admin | set | messages: + msg2543 |
| 2010-02-16 00:00:00 | admin | set | status: drafting -> review |
| 2008-10-05 00:00:00 | admin | set | messages: + msg1780 |
| 2008-10-05 00:00:00 | admin | set | status: review -> drafting |
| 2008-06-29 00:00:00 | admin | set | messages: + msg1703 |
| 2008-06-29 00:00:00 | admin | set | status: drafting -> review |
| 2007-05-06 00:00:00 | admin | set | messages: + msg1489 |
| 2007-05-06 00:00:00 | admin | set | status: open -> drafting |
| 2007-01-30 00:00:00 | admin | create | |