In Ansi C - where is “decay” defined, and where are all cases of documenting it?

From time to time, I come across the term “decay”, for example, when arrays are passed because the parameters of the function decay to a pointer or when functions decay to a pointer to a function. If I wrote the c compiler, where would I find the term "decay" officially defined and where will all cases of its occurrence be recorded?

+3
source share
4 answers

The official terminology in the standard for this is "lvalue conversion". In the current version of the standard (C11) you will find this in 6.3.2.1 p3.

+3
source

A second Google search yielded the following:

The K&R method of reducing arrays to pointers
 ---------------------------------------------
 K&R tried to create a unified treatment of arrays and pointers, one that 
 would expose rather than hide the array equation in the compiler code. 
 They found an elegant solution, albeit a bit complicated. The "ugly" 
 array equation is replaced in their formulation by four rules:

    1) An array of dimension N is a 1D array with
       elements that are arrays of dimension N-1.

    2) Pointer addition is defined by:

          ptr # n = ptr + n * size(type-pointed-into)

       "#" denotes here pointer addition to avoid 
       confusion with ordinary addition.
       The function "size()" returns object sizes.

    3) The famous "decay convention": an array is 
       treated as a pointer that points to the 
       first element of the array.

       The decay convention shouldn't be applied
       more than once to the same object.

    4) Taking a subscript with value i is equivalent 
       to the operation: "pointer-add i and then 
       type-dereference the sum", i.e.

          xxx[i] = *(xxx # i)


        When rule #4 + rule #3 are applied recursively 
        (this is the case of a multi-dimensional array), 
        only the data type is dereferenced and not the 
        pointer value, except on the last step.

Source

+1
source

C - .

, ISO/IEC 9899: 2011. 1999 1989 .

, 2011 :  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

0

, (= ) . , (, sizeof). .

0

All Articles