Created on 2007-03-09.00:00:00 last changed 178 months ago
[Voted into WP at March, 2010 meeting.]
Proposed resolution (October, 2009):
Change 9.2.9.7 [dcl.spec.auto] paragraph 3 as follows:
...Theauto shall appear as one of the decl-specifiers in the decl-specifier-seq and the decl-specifier-seq shall be followed by one or more init-declarators, each of which shall have a non-empty initializer.
Notes from the February, 2008 meeting:
It was agreed that the example should be ill-formed.
The auto specifier can be used only in certain contexts, as specified in 9.2.9.7 [dcl.spec.auto] paragraphs 2-3:
Otherwise (auto appearing with no type specifiers other than cv-qualifiers), 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 is allowed when declaring objects in a block (8.4 [stmt.block]), in namespace scope (6.4.6 [basic.scope.namespace]), and in a for-init-statement (8.6.4 [stmt.for]). 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 )
It was intended that auto could be used only at the top level of a declaration, but it is not clear whether this wording is sufficient to forbid usage like the following:
template <class T> struct A {}; template <class T> void f(A<T> x) {} void g() { f(A<short>()); A<auto> x = A<short>(); }
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-03-29 00:00:00 | admin | set | messages: + msg2689 |
2010-03-29 00:00:00 | admin | set | status: ready -> cd2 |
2009-11-08 00:00:00 | admin | set | messages: + msg2351 |
2009-11-08 00:00:00 | admin | set | status: drafting -> ready |
2008-03-17 00:00:00 | admin | set | messages: + msg1605 |
2008-03-17 00:00:00 | admin | set | status: open -> drafting |
2007-03-09 00:00:00 | admin | create |