cppcheck sept 18 redux

Henri Verbeet hverbeet at gmail.com
Tue Sep 22 10:05:38 CDT 2009


2009/9/22 Luke Benstead <kazade at gmail.com>:
> 2009/9/22 Ben Klein <shacklein at gmail.com>:
>> 2009/9/23 Luke Benstead <kazade at gmail.com>:
>>> 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 :)
>>
>> I believe it's because the array (as a pointer) is at the same
>> location as start of the struct (as a pointer). Compiler then applies
>> pointer arithmetic without dereferencing.
>>
>
> Ah, I see.. but in that case, how is an array different to using a
> pointer, like in Vitaliy's example? Surely that's the same thing
> essentially?
>
"s->pointer" refers to the value of the pointer if "pointer" is a
pointer, but to the address of the first array element if "pointer" is
an array. I.e. "&s->pointer[0]" as Nicolas posted.



More information about the wine-devel mailing list