1 msgMIPS pseudo-instruction expansion
2 msgOSX and gcc
1 msggcc-3.4.6 config options
1 msggcc-4.0.3 compilation issues on Linux
5 msgweak-attribute over-optimisation with 4.1
1 msg_mm_movpi64_epi64 does not generate MOVQ2DQ
1 msgDoubt
2 msgstl set
1 msgCompiling gcc 4.1 on solaris 2.8 64 bits

comparison of structures
\ José Bollo (18 May 2006)
. \ Fabian Cenedese (18 May 2006)
. \ cheng long (18 May 2006)

1 msgHelp needed for building GCC 4.1.0
5 msgHelp Needed for gcc on Linux x86_64
2 msgopen or fopen?
1 msgCompile gcc 4.1.0 hang on perl perl texi2pod.pl...
6 msgRe: Government Requirements - Proprietary Software
1 msgDP Server c++ Makefile FreeBSD
1 msgstd::vector does not independently call default...
2 msgBroadcast and Multicast using UDP
4 msgcan we define a comment?
4 msgproblem with building of libjava
Subject:comparison of structures
Group:Gcc-help
From:José Bollo
Date:18 May 2006


hi,

the following C code

typedef struct {
int32_t a;
void *b;
} S;
void fs() {
char t[255];
int i;
for(i=0;i<255;i++)
t[i]=(char)(i+1);
}
int cmp1(S a1, S a2) {
return !memcmp(&a1,&a2,sizeof(S));
}
int cmp2(S a1, S a2) {
return a1.a==a2.a && a1.b==a2.b;
}
void put(S y) {
int a,b;
S x;
x=y;
a=cmp1(x,y);
b=cmp2(x,y);
printf("a=%d b=%d\n",a,b);
}
int main() {
S a;
a.a=1;
a.b=&a;
fs();
put(a);
return 0;
}

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 ?

regards
josé


© 2004-2008 readlist.com