Skip to content

Commit c16551f

Browse files
committed
[dcl.array] No longer explain array subscript in terms of array-to-pointer conversion
1 parent b80d382 commit c16551f

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

source/declarations.tex

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,25 +3452,17 @@
34523452
The expression
34533453
\tcode{x3d[i]}
34543454
is equivalent to
3455-
\tcode{*(x3d + i)};
3456-
in that expression,
3457-
\tcode{x3d}
3458-
is subject to the array-to-pointer conversion\iref{conv.array}
3459-
and is first converted to
3460-
a pointer to a 2-dimensional
3461-
array with rank
3462-
$5 \times 7$
3463-
that points to the first element of \tcode{x3d}.
3464-
Then \tcode{i} is added,
3465-
which on typical implementations involves multiplying
3455+
\tcode{*(x3d + i)},
3456+
and is an lvalue denoting
3457+
the $\tcode{i}^\text{th}$ array element of
3458+
\tcode{x3d},
3459+
which is an array with rank $5 \times 7$.
3460+
On typical implementations,
3461+
computing the address of this two-dimensional array
3462+
involves multiplying
34663463
\tcode{i} by the
3467-
length of the object to which the pointer points,
3464+
length of the array in bytes,
34683465
which is \tcode{sizeof(int)}$ \times 5 \times 7$.
3469-
The result of the addition and indirection is
3470-
an lvalue denoting
3471-
the $\tcode{i}^\text{th}$ array element of
3472-
\tcode{x3d}
3473-
(an array of five arrays of seven integers).
34743466
If there is another subscript,
34753467
the same argument applies again, so
34763468
\tcode{x3d[i][j]} is

0 commit comments

Comments
 (0)