bug in compiling dhcpcd-1.3.17pl5 (surprisingly fixed with a printf!)
Olivier Baudron
Olivier.Baudron@ens.fr
Sat Mar 20 11:54:00 GMT 1999
Can someone try the following experiment (needs a modem-cable).
1. Download http://www.phystech.com/download/dhcpcd-1.3.17-pl5.tar.gz
2. untar it, cd in the directory and "make"
3. Execute dhcpcd
On my computer, dhcpcd does not work! (the checksum in the server response
fails)
Now, insert a printf("coucou\n") in the file udpipgen.c between lines 42 and 43.
The procedure in_cksum should look like:
unsigned short in_cksum(addr,len)
unsigned short *addr;
int len;
{
register int sum = 0;
u_short answer = 0;
register u_short *w = addr;
register int nleft = len;
while ( nleft > 1 )
{
sum += *w++;
nleft -= 2;
}
printf ("coucou\n");
if ( nleft == 1 )
{
*(u_char *)(&answer) = *(u_char *)w ;
sum += answer;
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;
return answer;
}
Now, re-compile the file and re-build the executable dhcpcd.
On my computer, dhcpcd works!!!!
I also noticed, that when the option -O2 is removed, all works fine.
I tried these experiments many times, and the results were confirmed each time.
I also isolated the procedure in_cksum in a separate file. When compiling this
specific file with no optimization or with the inserted line printf("...")
dhcpcd works, but when compiling with -O2 and with no inserted line printf
("...") dhcpcd fails. Therefore the bug in compilation really concerns the above
lines of code.
My system is:
Intel P133
Linux 2.2.3
egcs 1.1.2
binutils 2.9.1.0.15
libc6 2.0.7
Cheers,
Olivier.
More information about the Gcc-bugs
mailing list