This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: comparison of structures
- From: Fabian Cenedese <Cenedese at indel dot ch>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 18 May 2006 16:20:08 +0200
- Subject: 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