Re: comparison of structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux