A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/CWG/issues/1824.html below:

CWG Issue 1824

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13

1824. Completeness of return type vs point of instantiationSection: 9.3.4.6  [dcl.fct]     Status: CD4     Submitter: Steve Clamage     Date: 2013-12-19

[Moved to DR at the November, 2014 meeting.]

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.6.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)?

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.6.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).

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4