Created on 2013-12-19.00:00:00 last changed 94 months ago
[Moved to DR at the November, 2014 meeting.]
Proposed resolution (February, 2014):
Change 9.3.4.6 [dcl.fct] paragraph 9 as follows:
Types shall not be defined in return or parameter types. The type of a parameter or the return type for a function definition shall not be an incomplete class type (possibly cv-qualified) in the context of the function definition unless the function is deleted (9.5.3 [dcl.fct.def.delete])or the definition is nested within the member-specification for that class (including definitions in nested classes defined within the class).
Consider the following example:
template<typename T> struct A { T t; }; struct S { A<S> f() { return A<S>(); } };
According to 9.3.4.6 [dcl.fct] paragraph 9,
The type of a parameter or the return type for a function definition shall not be an incomplete class type (possibly cv-qualified) unless the function is deleted (9.5.3 [dcl.fct.def.delete]) or the definition is nested within the member-specification for that class (including definitions in nested classes defined within the class).
Thus type A<S> must be a complete type. The requirement for a complete type triggers the instantiation of the template, which requires that its template argument be complete in order to use it as the type of a non-static data member.
According to 13.8.4.1 [temp.point] paragraph 4, the point of instantiation of A<S> is “immediately preced[ing] the namespace scope declaration or definition that refers to the specialization.” Thus the point of instantiation precedes the definition of S, making this example ill-formed. Most or all current implementations accept the example, however.
Perhaps the specification in 9.3.4.6 [dcl.fct] ought to say that the completeness of the type is checked from the context of the function body (at which S is a complete type)?
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-02-06 00:00:00 | admin | set | status: drwp -> cd4 |
2015-05-25 00:00:00 | admin | set | status: dr -> drwp |
2015-04-13 00:00:00 | admin | set | messages: + msg5375 |
2014-11-24 00:00:00 | admin | set | status: ready -> dr |
2014-03-03 00:00:00 | admin | set | messages: + msg4829 |
2014-03-03 00:00:00 | admin | set | status: open -> ready |
2013-12-19 00:00:00 | admin | create |