Topic: Defect Report: Erroneous restrictions on variables which can be initialized by arbitrary expressions
Author: "whyglinux" <whyglinux@gmail.com>
Date: Tue, 30 Jan 2007 09:59:11 CST Raw View
8.5 Initializers[dcl.init], paragraph 2 reads,
"Automatic, register, static, and external variables of namespace
scope can be initialized by arbitrary expressions involving literals
and previously declared variables and functions."
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 appeared 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
is 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: 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:
External variables of namespace scope can be initialized by arbitrary
expressions involving literals and previously declared variables and
functions.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]