Title
Semantic constraints on non-dependent names
Status
tc1
Section
_N4868_.13.8.4 [temp.nondep]
Submitter
Mike Miller

Created on 2000-02-23.00:00:00 last changed 263 months ago

Messages

Date: 2000-04-15.00:00:00

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.
Date: 2021-02-24.00:00:00

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.
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetmessages: + msg329
2000-05-21 00:00:00adminsetstatus: open -> ready
2000-02-23 00:00:00admincreate