News for hackers. Stuff that matters.
Re:Single assignment C by hello_hi on Sunday December 22, 2013 @10:08AM (#6950467)
That's not a 2D array, it's a jagged array. You're paying for an extra pointer dereference.
Re:Single assignment C by Peaker on Sunday December 22, 2013 @10:15AM (#6950482)
You're wrong. Operationally, it is equivalent to:

  int x_1d[8300];
Where x[a][b] is x_1d[a + 83*b];

An array of arrays is contiguous in memory. There are no pointers involved until you take the (r)value of the array or one of the inner arrays, at which point it is degraded to be a pointer to the array's first element, as always.

Re:Single assignment C by mpweiher on Sunday December 22, 2013 @11:29AM (#6950705)
Where hello_hi might have gotten confused is that in usage, a pointer of array pointers looks the same as a 2D array. So if you only see x[a][b] it could actually be dereferencing an array of pointers to integers.

Since we have the declaration, it's unambiguously the 2D array that you described.

EDIT: I might be seeing things, but I think you have your order mixed up, x[a][b] is not x_1d[a + 83b], but rather x_1d[a83+b]

Re:Single assignment C by Peaker on Sunday December 22, 2013 @08:54PM (#6952667)
Your edit is correct, thanks for the correction!
Re:Single assignment C by norswap on Sunday December 22, 2013 @10:34AM (#6950522)
And I'll also add that this is not an optimization, it's guaranteed by the standard.