From c16551f9090a34c565085f96bd3828f6052c517b Mon Sep 17 00:00:00 2001 From: Eisenwave Date: Thu, 6 Jun 2024 18:24:12 +0200 Subject: [PATCH] [dcl.array] No longer explain array subscript in terms of array-to-pointer conversion --- source/declarations.tex | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index 4034565e2b..423b8cecb0 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -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