Change 3.7.2 basic.stc.auto paragraph 1 as indicated:The storage class specifiersstatic
andauto
are related to storage duration as described below.
Local objects explicitly declaredChange 5.3.4 paragraph 2 as indicated:auto
orregister
or not explicitly declaredstatic
orextern
have automatic storage duration. The storage for these objects lasts until the block in which they are created exits.
If theChange 6.4 paragraph 2 as indicated:auto
type-specifier appears in the type-specifier-seq of a new-type-id or type-id of a new-expression,the type-specifier-seq shall contain no other type-specifiers except cv-qualifiers, andthe new-expression shall contain a new-initializer of the form( assignment-expression )
... If the auto type-specifier appears in the type-specifier-seq,Add a grammar production to the end of 7.1.6 dcl.type paragraph 1:the type-specifier-seq shall contain no other type-specifiers except cv-qualifiers, andthe type of the identifier being declared is deduced from the assignment-expression as described in 7.1.6.4 dcl.spec.auto.
In 7.1.6 dcl.type paragraph 2, change as indicated:type-specifier-seq: type-specifier type-specifier-seqopt
As a general rule, at most one type-specifier is allowed in the complete decl-specifier-seq of a declaration or in a type-specifier-seq. The only exceptions to this rule are the following: ...Change 7.1.6.4 dcl.type.auto paragraphs 1-3 as indicated:
auto can be combined with any type specifier except itself.
Remove the grammar production from 8.1 dcl.name paragraph 1:
Theauto
type-specifier has two meanings depending on the context of its use. In a decl-specifier-seq that contains at least one type-specifier (in addition to auto) that is not a cv-qualifier, theauto
type-specifier specifies that the object named in the declaration has automatic storage duration. The decl-specifier-seq shall contain no storage-class-specifiers. This use of theauto
specifier shall only be applied to names of objects declared in a block (6.3) or to function parameters (8.4).
Otherwise (Theauto
appearing with no type specifiers other than cv-qualifiers), theauto
type-specifier signifies that the type of an object being declared shall be deduced from its initializer. The name of the object being declared shall not appear in the initializer expression.
This use of autoTheauto
type-specifier is allowed when declaring objects in a block (6.3), in namespace scope (3.3.5), and in a for-init-statement (6.5.3). The decl-specifier-seq shall be followed by one or more init-declarators, each of which shall have a non-empty initializer of either of the following forms:= assignment-expression ( assignment-expression )[ Example: auto x = 5; // OK: x has type int const auto *v = &x, u = 6; // OK: v has type const int*, u has type const int static auto y = 0.0; // OK: y has type doublestatic auto int z; // error: auto and static conflictauto int r; //OK: r has type interror: auto is not a storage-class-specifier -- end example ]
Change 8.3 dcl.meaning paragraph 2 as indicated:type-specifier-seq: type-specifier type-specifier-seqopt
Change 8.3.4 dcl.array paragraph 1 as indicated:An auto,A static, extern, register, mutable, friend, inline, virtual, or typedef specifier applies directly to each declarator-id in an init-declarator-list; the type specified for each declarator-id depends on both the decl-specifier-seq and its declarator.
In a declaration T D where D has the formChange 9.2 class.mem paragraph 6 as indicated:D1 [ constant-expressionopt ]and the type of the identifier in the declaration T D1 is "derived-declarator-type-list T," then the type of the identifier of D is an array type; if the type of the identifier of D contains theauto
type deductiontype-specifier, the program is ill-formed. ...
A member shall not be declaredChange the example in 9.8 class.local paragraph 1 as indicated:to have automatic storage duration (auto, register) orwith theextern
orregister
storage-class-specifiers.
[ Example:Add an element to C.1.5 diff.dcl (not shown in bold here):int x; void f() { static int s ; int x; extern int g(); struct local { int g() { return x; } // error: x-- end example ]is autohas automatic storage duration int h() { return s; } // OK int k() { return ::x; } // OK int l() { return g(); } // OK }; // ... } local* p = 0; // error: local not in scope
7.1.6.4 dcl.type.autoIn the index, remove the entries forChange: The keyword
auto
cannot be used as a storage class specifier.Example:
void f() { auto int x; // valid C, invalid C++ }Rationale: Allowing the use ofauto
to deduce the type of a variable from its initializer results in undesired interpretations ofauto
as a storage class specifier in certain contexts.
Effect on original feature: Deletion of semantically well-defined feature.
Difficulty of converting: Syntactic transformation.
How widely used: Rare.
Change the index entry forauto destruction of, initialization, auto
storage duration, 60autoautomatic, 61