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
[dcl.struct.bind] structured bindings vs. potentially conflict #5201
Comments
A declaration can have several declarations inside, and I think that's exactly what a structure binding declaration does: @opensdh, it looks like [basic.link] p11 should mention structured bindings. basic.def.odr, after my rewrite in a recent core issue, should already say the right thing that we can't have a redefinition of a structured binding. |
Sure,
The wording "a declaration of E" sounds like that the declaration is uniquely possessed by the entity auto [a, b] = f(); // #1
int c, d; // #2 Either at
which can eliminate the puzzle of the "ownership". Also, [basic.scope.scope] p4 has a bit issue on structured binding cases
In this case auto [x, x] = f(); there is only one declaration here, which introduces two structured binding with the same name. So, we couldn't determine certain concepts based on the "correspond". |
As I said, the model here is that |
I agree with this point since we have [dcl.decl.general] p3 that explicitly clarifies this point
In other words, each init-declarator is considered as if it were in a single corresponding declaration. But, how about a structured binding declaration? we never define a similar concept to clarify that each structured binding has its own declaration for analysis. |
It should be treated the same, but we seem to be lacking words to that effect. |
Well, that's a part of what I'm looking forward to in this issue. We should specify that part in the current draft. |
@opensdh As have discussed in this thread: https://stackoverflow.com/questions/65729849/it-seems-the-current-standard-draft-cannot-interpret-why-two-structured-binding
There is no provision in the current draft that can point out the name
x
at#1
potentially conflicts withx
at#2
. In short, [basic.scope.scope] p4 is saying they correspond, [basic.link] p8 is saying they declare the same entity, obviously, their shared name denotes the same entity, and also [basic.link] p11 didn't even mention structured bindings. Finally, [basic.def.odr] also didn't mention it. Furthermore, except for this example, there is also a similar example:[dcl.struct.bind] p1 is saying
So, each name of the identifier denotes the corresponding structured binding introduced by a structured binding declaration. Obviously, [basic.pre] p5 is wrong in this case, which says
I would argue that a structured binding declaration can introduce multiple structured bindings(entities). Obviously, the relationship between them is not one-to-one. Moreover, [basic.pre] p3 admits that "structured binding" itself is a distinct category of the entity. So, we should regulate which structured bindings declare the same entity or not.
@opensdh has given the patch but it seems to be not ok for the second example
The condition of [basic.link] is
In the second example of this issue, the entity E denoted by the two names
x
is introduced by the same structured binding declaration. Presumably, [basic.link] also never intends to compare any two declarations by using the same declaration as two declarations, this does not make sense.The text was updated successfully, but these errors were encountered: