cppcheck sept 18 redux

Ove Kaaven ovek at arcticnet.no
Tue Sep 22 12:45:45 CDT 2009


Luke Benstead skrev:
> If it IS the case that this doesn't cause a crash and is perfectly
> valid, can someone explain to me how/why this works? Or point me (no
> pun intended) to the bit in the C spec that explains it? Coz the way I
> read it, it has to dereference dmW, otherwise how would the compiler
> find the address of the array? ... so confused :)

Kernighan & Ritchie, "The C Programming Language", 2nd edition, section
5.3, page 99:

"Since the name of an array is a synonym for the location of the initial
element, the assignment pa=&a[0] can also be written as pa=a"

The reference part, section A7.1, goes into more detail. "If the type of
an expression or subexpression is array of T, for some type T, then the
value of the expression is a pointer to the first object in the array,
and the type of the expression is altered to pointer to T." It then
lists a few exceptions, including the & operator is used (hence, a and
&a returns the exact same thing if a is an array).



More information about the wine-devel mailing list