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

2024-04-18


206. Semantic constraints on non-dependent names

Section: _N4868_.13.8.4  [temp.nondep]     Status: TC1     Submitter: Mike Miller     Date: 23 Feb 2000

At what point are semantic constraints applied to uses of non-dependent names in template definitions? According to _N4868_.13.8.4 [temp.nondep] , such names are looked up and bound at the point at which they are used, i.e., the point of definition and not the point of instantiation. However, the text does not mention the checking of semantic constraints.

Contrast this omission with the treatment of names in default argument expressions given in 9.3.4.7 [dcl.fct.default] paragraph 5, where the treatment of semantic constraints is explicit:

The names in the expression are bound, and the semantic constraints are checked, at the point where the default argument expression appears.
The following code is an example of where this distinction matters:
    struct S;

    template <class T> struct Q {
        S s;    // incomplete type if semantic constraints
                // are applied in the definition context
    };

    struct S { };

    // Point of instantiation of Q<int>; S is complete here

    Q<int> si;
There is real-world code that depends on late checking of semantic constraints. The Standard should be explicit about whether this code is broken or not.

Proposed resolution (10/00):

In 13.8 [temp.res] paragraph 7, add the following immediately preceding the note:

If a type used in a non-dependent name is incomplete at the point at which a template is defined but is complete at the point at which an instantiation is done, and if the completeness of that type affects whether or not the program is well-formed or affects the semantics of the program, the program is ill-formed; no diagnostic is required.