N2546 Removal of auto as a storage-class specifier (original) (raw)

The auto 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, the auto type-specifier specifies that the object named in the declaration has automatic storage duration. The_decl-specifier-seq shall contain no_storage-class-specifier_s. This use of the autospecifier shall only be applied to names of objects declared in a block (6.3) or to function parameters (8.4).

Otherwise (auto appearing with no type specifiers other than cv-qualifiers), the The auto 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 auto The auto 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 double static auto int z; // error: auto and static conflict auto int r; // OK: r has type interror: auto is not a storage-class-specifier -- end example ]