comparison of structures

Fabian Cenedese Cenedese@indel.ch
Thu May 18 14:19:00 GMT 2006


>the following C code 
>
>typedef struct {
>    int32_t a;
>    void *b;
>} S;
>
>compiled for my linux x86_64 using the amd64 ABI (-march=athlon64) with gcc 
>3.4.4 prints "a=0 b=1"
>
>i have seen why and it is clear to me how a such result is produced.
>i think that it is not a bug and that the structure can not be compared using 
>'memcmp'.
>
>do you agree or it a bug ?

You can use memcmp if you fill up the struct with a dummy value that you
can set explicitely. Or use a memset(&a, 0, sizeof(S)) before doing any
work. Both are workarounds but I wouldn't say that it's a bug.

bye  Fabi




More information about the Gcc-help mailing list