|
From: Dominic M. <dma...@ai...> - 2003-04-04 18:53:32
|
Hi,
I've been using valgrind for about six months, and it's been wonderful to
have. I was spoiled having access to purify on Solaris machines for a
while, and missed having something similar on Linux. Many thanks to
Julian Seward and everyone else who contributed to its development.
I've included a very small program that generates different output when
it's run through valgrind. I noticed the error while I was debugging a
function to quickly check if an array of single-precision floats has any
NaNs in it - it turns out that doing a bitwise test is 2-3x faster than
calling the finite() function.
Anyway, the error only occurs if you compile it with the options:
gcc -O2 -mcpu=pentiumpro -march=pentiumpro
However, the exact same error occurs whether I compile the program with
gcc 2.96 (RedHat 7.3's version) or gcc 3.2.
The correct output of the program is "0.000000". When run under valgrind
1.9.4, it outputs "1.000000".
I hope this helps! It's easy enough for me to work around, but I can only
guess that this is probably the symptom of a bug that could manifest
itself in other ways.
- Dominic
#include <stdio.h>
int main(int argc, char **argv)
{
union {
float a[2];
int b[2];
} u;
u.a[0] = 0.0 / 0.0;
u.a[1] = ((*u.b & 0x7FC00000) != 0x7FC00000);
printf("%f\n", u.a[1]);
return 0;
}
|