This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: comparison of structures


>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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]