const-qualified variables with
registerstorage class to be initialized
const-qualified variables, one with
register storage class and one
register unsigned char const oops; auto unsigned char const rando;
rando doesn't have
unsigned char it could always be evaluated and
would provide an unspecific value.
In contrast to that
oops can never be used for other
effects than to feed it to the
sizeof operator. All
other access is inhibited by the standard, either as constraint
violation or as resulting in undefined behavior:
constqualified it can not be assigned to or otherwise modified.
registerclass, its address cannot be taken. So it can't even be modified indirectly by any other means.
registerclass and not initialized it cannot be evaluated.
A compiler can easily detect that such a variable is not initialized at the point of the declaration itself. No complicated flow analysis has to be performed to see if it could have been initialized later or if the underlying object could have been aliased and then assigned with a value.
After 6.7.9p5 add a new paragraph:
If the declaration of an identifier has
storage class and the type of the declaration is
qualified an initialization of the object shall be provided to form
a full definition of the object.
If the feature request to allow for
register storage class in file scope,
the terminating subsentence would be important to clarify that the
initializer is expected at any occurence of the declaration of the
identifier and thus that there can be only exactly one
declaration/definition of it.
This would defer from a
static declaration, that first
can be given without initialization (thus being only a declaration
and not a definition) and then later be defined by providing an
initializer. Here a compiler could defer to establish the the value
of the object, since he may always refer to the object through its
Another, but unsatisfactory solution would be to treat these objects
the same as for storage class
static and to modify the
second phrase of 6.7.9p10
If an object is not initialized explicitly that has static storage
duration, thread storage duration, or is of
storage class and of a
const qualified type then: