|
From: John R. <jr...@Bi...> - 2003-11-20 21:58:57
|
Valgrind 2.0.0 (memcheck) complains about a bit that is not uninitialized.
-----jfrtest1.c
int
test1()
{
unsigned x; /* uninitialized */
x &= 0x0000000c; /* possible 0, 4, 8, 12 */
if (2 & (x % 15)) { /* memcheck complains but should not */
return 1;
}
else {
return 0;
}
}
int
main()
{
return test1();
}
-----end jfrtest1.c
$ gcc -g -o jfrtest1 jfrtest1.c
$ valgrind ./jfrtest1
==7084== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==7084== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==7084== Using valgrind-2.0.0, a program supervision framework for x86-linux.
==7084== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==7084== Estimated CPU clock rate is 1619 MHz
==7084== For more details, rerun with: -v
==7084==
==7084== Conditional jump or move depends on uninitialised value(s)
==7084== at 0x8048318: test1 (jfrtest1.c:6)
==7084== by 0x8048343: main (jfrtest1.c:17)
==7084== by 0x40247AB6: __libc_start_main (in /lib/libc-2.3.2.so)
==7084== by 0x8048264: ??? (start.S:81)
$ gdb ./jfrtest1 ## generated assembly code looks OK
(gdb) x/23i test1
0x80482f4 <test1>: push %ebp
0x80482f5 <test1+1>: mov %esp,%ebp
0x80482f7 <test1+3>: sub $0xc,%esp
0x80482fa <test1+6>: lea 0xfffffffc(%ebp),%eax
0x80482fd <test1+9>: andl $0xc,(%eax)
0x8048300 <test1+12>: mov 0xfffffffc(%ebp),%edx
0x8048303 <test1+15>: mov %edx,%eax
0x8048305 <test1+17>: mov $0xf,%ecx
0x804830a <test1+22>: mov $0x0,%edx
0x804830f <test1+27>: div %ecx
0x8048311 <test1+29>: mov %edx,%eax
0x8048313 <test1+31>: and $0x2,%eax
0x8048316 <test1+34>: test %eax,%eax
0x8048318 <test1+36>: je 0x8048323 <test1+47> ## complaint here
0x804831a <test1+38>: movl $0x1,0xfffffff8(%ebp)
0x8048321 <test1+45>: jmp 0x804832a <test1+54>
0x8048323 <test1+47>: movl $0x0,0xfffffff8(%ebp)
0x804832a <test1+54>: mov 0xfffffff8(%ebp),%eax
0x804832d <test1+57>: leave
0x804832e <test1+58>: ret
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
glibc-2.3.2-27.9.6
System is Red Hat 9: 2.4.20-20.9.
--
John Reiser, jr...@Bi...
|