-
Notifications
You must be signed in to change notification settings - Fork 771
The definition of what entity denoted by a qualified-id is not clear #5346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The cross-reference is present not for "denotes", but for the definition of qualified name lookup. @opensdh, the suggested change seems to better map the grammar qualified-id to the subject of interest for [basic.lookup.qual], which is a qualified name. |
@jensmaurer @opensdh A special case is: this->~C(); // ~C is an unqualified-id
this->C::~C(); // C::~C is a qualified-id where the qualified-id
Anyway, the result of the lookup could arguably say to be the injected-class-name of |
An entity can be a result only if lookup finds function(s). If it finds a variable or NSDM, the result is the corresponding object, not the entity. |
This touches upon the unsolved variable / object confusion. Note, however, that |
That is the reason why [basic.pre] p3 admits object and reference are entities but variable is not. If an (unqualified or qualified) name is resolved to be introduced by a declaration of an object, the name just denotes an object. |
@jensmaurer But, @languagelawyer's opinion introduces another issue that, consider a more simple case, which is: int i = 0; // a declaration of an object.
i;
new(&i) int{1};
i;
new(&i) int{2};
i;
new(&i) int{3};
i; [basic.lookup] is only able to resolve the name
So, which object does the name
An unqualified-id is an expression. So, should we change the above bullet to
|
I think we agree that lookup should find the variable "i", and it's conceptually an additional step to determine the object or function to which the glvalue named as "i" refers. Unfortunately, cleaning this up is a larger undertaking. My guess is we want to restrict "entity" to things that are syntactically declared and thus have a name (variables, data members, structured bindings, function declarations) and use "object or function" for the target of a glvalue. We can probably conflate "function declaration" and "function", because there is a 1:1 mapping. |
It sounds like the step is the duty of the evaluation of the (glvalue) expression, which determines the actual object/function the name "i" denotes at that moment. Instead, [basic.lookup] is just concerned about the declaration that introduces the name, which restricts what kind of entities the name can denote, and so, the name should have the corresponding properties introduced by the declaration, which will determine what context in which the name is syntactically and semantically correct. In other words, [basic.lookup] cannot determine the result of the expression(id-expression), if we read "result" as what actual |
Mostly agreed. [basic.lookup] actually uniquely determines the entity to which the name refers (except for functions because of overloading). |
So, that is the motivation why I want to change the definition to that as written in #5346 (comment), which might avoid the hazy regarding "result". |
I agree that the original suggestion is a (minor) improvement. I also agree that there isn't really any wording that says that lookup can ever find a destructor: [class.dtor]/1 explains how to interpret a declarator-id that begins with |
@opensdh How to fix the confusion to the "result" between [basic.lookup] and "expression evaluation". The definition of the result of an unqualified-id or qualified-id that is a glvalue relies on what entity the (unqualified or qualified ) name denotes. However, [basic.lookup] only associates the name with the found declaration, it cannot determine which actual |
Precisely because lookup as a static operation cannot identify a particular object, I strongly believe that we should stop saying that an object is an "entity". Then [expr.prim.id.general] can describe how the lookup result (e.g., a variable) is used to identify an object/function in much the same way as [expr.ref] describes how a lookup result (e.g., non-static data member) is used to identify a (sub)object or other member. |
That means, we must firstly clarify the following issues:
|
«which object is associated with a variable» should be enough |
Maybe not enough. Since we have [basic.stc.thread]
|
«should be enough» does include changing places which care about references for no reason. |
Seems right that we don't need to concern with reference. Except for objects, functions maybe? |
Now that I think about it more, I see that the resolution to the separate(d) #5449 (along with properly handling the other special case of concept-ids) will in fact invalidate the simple solution proposed here; I'll address both of these in my current paper. |
Please also look into this issue cplusplus/CWG#44 |
[expr.prim.id.qual] p5 states that
The emphasized subclause has no actual interpretation. [basic.pre] p5 define what entity is denoted by a name.
So, I think [expr.prim.id.qual] p5 should be changed to:
The text was updated successfully, but these errors were encountered: