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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3452,25 +3452,17 @@
The expression
\tcode{x3d[i]}
is equivalent to
\tcode{*(x3d + i)};
in that expression,
\tcode{x3d}
is subject to the array-to-pointer conversion\iref{conv.array}
and is first converted to
a pointer to a 2-dimensional
array with rank
$5 \times 7$
that points to the first element of \tcode{x3d}.
Then \tcode{i} is added,
which on typical implementations involves multiplying
\tcode{*(x3d + i)},
and is an lvalue denoting
the $\tcode{i}^\text{th}$ array element of
\tcode{x3d},
which is an array with rank $5 \times 7$.
On typical implementations,
computing the address of this two-dimensional array
involves multiplying
\tcode{i} by the
length of the object to which the pointer points,
length of the array in bytes,
which is \tcode{sizeof(int)}$ \times 5 \times 7$.
The result of the addition and indirection is
an lvalue denoting
the $\tcode{i}^\text{th}$ array element of
\tcode{x3d}
(an array of five arrays of seven integers).
If there is another subscript,
the same argument applies again, so
\tcode{x3d[i][j]} is
Expand Down
Loading