
When evaluating comparison expressions, the "usual arithmetic conversions" mandated by C standard (ISO/IEC 9899 #6.3.1.8) are NOT done.
In the cases below note that GDB returns the mathematically correct result, but this is not conforming to C standard and to GDB documentation that says:
"The usual way to examine data in your program is with the `print' command (abbreviated `p'), or its synonym `inspect'. It evaluates and prints the value of an expression of the language your program is written in"
GNU gdb Red Hat Linux (6.3.0.0-1.134.fc5rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) print (float)123456792.0 > 123456789 $1 = true (gdb) print (float)123456792.0 > (float)123456789 $2 = false (gdb) print 123456789123456784.0 < 123456789123456789LL $3 = true (gdb) print 123456789123456784.0 < (double)123456789123456789LL $4 = false
participants (1)
-
Abramo Bagnara