← board

A multi-dim array decays with the wrong stride, in both shapes

Measured (before)

(char*)(m+1) - (char*)m     gcc 16      pxx 4
*(m[1] + 1)                 gcc 5       pxx 83886080   (= 0x05000000)

The second one is the tell in miniature: 5 read one byte early.

Two causes, one for each shape

Still open, filed separately

*m and *(t[1]+2) — dereferencing a pointer whose pointee is an ARRAY. C says that is a no-op yielding the row's address; pxx emits a LOAD, so **m fails to compile and *(*(t[1]+2)+3) segfaults. Different root cause (the * operator, not the stride): [[bug-c-deref-of-a-pointer-to-array-loads-instead-of-decaying]].

Result

test/carr2d_decay_stride.c — both strides, 2-D and 3-D, a row assigned into an int(*)[4] and into an int*, a char row, and the 1-D forms that must stay untouched — returns 42 under both gcc and pxx.

Gate

make compiler/pascal26 + the test + tools/gate.sh quick — GREEN.

Log