Skip to content

[dcl.array] No longer explain array subscript in terms of array-to-pointer conversion #7053

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

Closed

Conversation

Eisenwave
Copy link
Member

@Eisenwave Eisenwave commented Jun 6, 2024

Fixes #7052.

image

Verified

This commit was signed with the committer’s verified signature.
Eisenwave Jan Schultke
…inter conversion
@jensmaurer
Copy link
Member

I'm not seeing a problem with the original formulation.

The expression x3d[i] is equivalent to *(x3d + i); in that expression, x3d is subject to the array-to-pointer conversion...

It's certainly true that in the expression "*(x3d + i)", x3d is subject to the array-to-pointer conversion. A small improvement might be to add a cross-reference to [expr.sub] after "equivalent to blah", to get the caveats visible.

@Eisenwave
Copy link
Member Author

I'm not seeing a problem with the original formulation.

I think you're right, at least with the current wording. If we say that it's equivalent to *(x3d + i), then array-to-pointer conversion really takes places.

If CWG2548 had been accepted, it would definitely be wrong though, as the wording would be

The result of the expression E1[E2] is identical (by definition) to that of *((E1)+(E2))

If only the result, but not the remaining semantics are equivalent, then array-to-pointer conversion doesn't really take place.

Even though you're right right now, I still don't favor the current wording. The note is intended to explain multi-dimensional subscript math, and this side tangent on array-to-pointer conversion isn't making it easier to understand. Depending on how [expr.sub] changes (and there have been a fair amount of historical/proposed changes), this side tangent becomes less relevant or simply wrong.

@jensmaurer
Copy link
Member

In short, the status quo of this pull request is not what we want.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Jun 10, 2024
@Eisenwave
Copy link
Member Author

I'm closing this because [dcl.array] already has a reference to [expr.sub], so neither the proposed changes nor the possible small alternative can be completed here.

@Eisenwave Eisenwave closed this Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[dcl.array] Subscript for arrays no longer performs array-to-pointer conversion
2 participants