0

If we reference an array, like

int array[10];
int *p = &array;

in GCC we have that p == array, or p == *p.

Beside the rationale explained in other answer (see here), is that a standard and defined behaviur, or some specific implementation could generate different address?

edit: to be clear the question is: is this in the C standard, and if it is, since when?

Lesto
  • 2,260
  • 2
  • 19
  • 26
  • `p == array` or `p == *p` are mistakes in Standard C, it's a gcc extension to allow that – M.M Jan 20 '18 at 00:22
  • What is it about the answers that you find unsatisfactory? – jxh Jan 20 '18 at 00:30
  • @M.M find a source and make an answer, i will accept it – Lesto Jan 20 '18 at 09:03
  • @jxh they explain WHY but not if it is STANDARD C and what standard. – Lesto Jan 20 '18 at 09:03
  • The citations into the C standard is not really interesting. If you have a copy, look for the definition of an array. Then consider how `int x` differs from `int x[1]`. – jxh Jan 20 '18 at 09:26
  • @jxh is not *interesting*? then if you decide to use &array are you sure this is going to work across all compiler, or across compiler updates? Plus side, if NOT a standard, and if tehre are different implementation, would not be *interesting* to learn their reasoning? My question is clear and the answer should be "YES, SINCE Cxx" or "NO" – Lesto Jan 20 '18 at 09:41
  • I only mean it is not interesting because there are two definitions: array, and address-of operator. – jxh Jan 21 '18 at 00:10

0 Answers0