0

I recently noticed that

void foo(int array[10]); 

Does not load the stack with the content of array when foo is called, so the declaration is equivalent to:

void foo(int *array):

I would like to find the section in the C99 standard that assert this behavior, but I don't find anything or I don't know what I should search for. So far I tried by reference, by value, function call, passing arguments, ...

nowox
  • 25,978
  • 39
  • 143
  • 293

1 Answers1

3

C11 6.7.6.3 §7. (C99 6.7.5.3 §7)

A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation.

The term is formally named "array adjustment". Informally outside the C standard, it is usually referred to as "array decay".

Lundin
  • 195,001
  • 40
  • 254
  • 396
  • 3
    @nowox I've probably just been reading the standard far too much. – Lundin Mar 27 '18 at 14:51
  • "Array adjustment" is a good term for it, although I've never encountered anyone referring to it as "array decay" (although "array decay" is a common way of referring to the automatic conversion of an lvalue of array type to a (non-lvalue) pointer). – Ian Abbott Mar 27 '18 at 15:07
  • @IanAbbott Yeah, the term array decay is sloppily used both to describe when an array type is used in an expression, and when it is part of a parameter list. See [this discussion](https://stackoverflow.com/questions/48868367/whats-a-modern-term-for-array-pointer-equivalence). – Lundin Mar 27 '18 at 15:16