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

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

Messages

Date: 2000-04-15.00:00:00

Proposed resolution (10/00):

In 17.7 [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: 2003-04-25.00:00:00

At what point are semantic constraints applied to uses of non-dependent names in template definitions? According to 17.7.3 [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 11.3.6 [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