cppcheck sept 18 redux

Luke Benstead kazade at gmail.com
Tue Sep 22 09:28:16 CDT 2009


2009/9/22 Ben Klein <shacklein at gmail.com>:
> 2009/9/22 Vitaliy Margolen <wine-devel at kievinfo.com>:
>> Mike Kaplinskiy wrote:
>>> It actually does not dereference anything. Try passing null into the
>>> function - it will work just fine. This is a special case because the
>>> array isn't dynamically allocated but is part of the struct, which
>>> means that dmW->dmFormName == (dmW+__offset of dmFormName) and not
>>> *(dmW+__offset of dmFormName). You can try writing a test program
>>> yourself - it will run just fine.
>> It does dereference the pointer. Here is your simple test. Compile it and
>> run it. See what happens.
>>
>> #include <stdio.h>
>>
>> typedef struct _s_test
>> {
>>    void *pointer;
>
> No. Array, not pointer. E.g.:
>    int array[1];
>
>> }  s_test;
>
>
>

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 :)

Luke.



More information about the wine-devel mailing list