cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[temp.res.general] Dependent and type-only context terminal name without typename considered type? #512

Closed ranaanoop closed 3 months ago

ranaanoop commented 3 months ago

Full name of submitter: Anoop Rana

Reference (section label): [temp.res.general]

Issue description:

Currently, temp.res.general says:

A qualified-id whose terminal name is dependent and that is in a type-only context is considered to denote a type. A name that refers to a using-declarator whose terminal name is dependent is interpreted as a typedef-name if the using-declarator uses the keyword typename.

[Example 6:
 template <class T> void f(int i) {
 T::x * i;         // expression, not the declaration of a variable i
}
... end example]

The highlightted part(in bold) quoted above seems to imply that T::x is considered to denote a type. This means that T::x *i; should be a declaration not an expression as per the first part of quoted reference. But the comment in the example code says otherwise.

jensmaurer commented 3 months ago

Why do you believe this is a type-only context? Your situation doesn't fit any of the categories in [temp.res.general] p4.

ranaanoop commented 3 months ago

Why do you believe this is a type-only context?

@jensmaurer Because the qualified name x is the terminal name of nested-name-specifier. So as per temp.res.general#4.1, this is type-only context.

jensmaurer commented 3 months ago

The T::x in your example is not a nested-name-specifier, it's a qualified-id whose nested-name-specifier is T::.

A nested-name-specifier always ends with ::; see [expr.prim.id.qual] before p1.