Bug in valarith.c:value_equal()?
Mark Kettenis
kettenis@gnu.org
Tue Feb 8 10:11:00 GMT 2005
I've found the cause of the testsuite problems I reported yesterday.
The additional testsuite failures are intermittent. If you look
careful at the gdb.mi/mi-var-cmd.exp test you'll see that the test is
checking whether some uninitialized local variables have been changed.
The testsuite failures indicate that sometimes, the floating-point
variables change unexpectedly. Some further investigation showed that
these unexpected changes happened when the (unitialized) variables
were NaNs. All of a sudden things make sense. The variables don't
really change. GDB tries to determine whether a variable changes by
comparing its current value to a previous value. This is done by
calling valarith.c:value_equal(). For floating-point variables, this
function does the following check:
return value_as_double (arg1) == value_as_double (arg2);
Now in C this will return 0, if ARG1 and ARG2 are NaN, even if they
are bit for bit equal.
Actually I think the implementation of valarithm.c:value_equal() is
right; when GDB evaluates expressions NaN == NaN should be zero.
Therefore I think we shouldn't use this function when establishing
when a variable has been changed. Does it make sense to simply do a
bit-for-bit comparison in that case?
Mark
More information about the Gdb
mailing list