Dear sirs/madams, I think I found a bug in gdb. (1) Abstract The language is C. Let the type of a variable 'a' is 'foo', which is a typedef of 'float' or 'double'. When 'a' appears in the expression of print command, it is evaluated as an integer. Exception is only when 'print a' is the command, the result is correct. (2) Environment Machine: SunOS 5.5.1 Generic_103640-31 sun4m sparc sun4m Version: GNU gdb 4.17 This GDB was configured as "sparc-sun-solaris2.5.1". (3) Example (3-1) Source Program compile it with -DDEBUG1 or -DDEBUG2 or -DDEBUG3 >> typedef double DOUBLE64; >> typedef float FLOAT32; >> >> main() >> { >> #ifdef DEBUG1 >> DOUBLE64 a, b; >> FLOAT32 c, d; >> char *mode = "DEBUG1"; >> #endif >> #ifdef DEBUG2 >> double a, b; >> float c, d; >> char *mode = "DEBUG2"; >> #endif >> #ifdef DEBUG3 >> DOUBLE64 a, b; >> float c, d; >> char *mode = "DEBUG3"; >> #endif >> >> a = 0.1; >> b = 0.2; >> c = 0.1; >> d = 0.2; >> >> printf("start \n"); >> printf("a*b= %g\n", a*b); >> printf("c*d= %g\n", c*d); >> printf("end \n"); >> exit(0); >> } (3-2)results (3-2-1) -DDEBUG1 >> Current directory is ~/VVV/src/test_gdb/ >> GNU gdb 4.17 >> Copyright 1998 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 "sparc-sun-solaris2.5.1"... >> (gdb) b main >> Breakpoint 1 at 0x10d80: file main.c, line 9. >> (gdb) run >> Starting program: /home/yoshimi/VVV/src/test_gdb/testrng >> >> Breakpoint 1, main () at main.c:9 >> (gdb) s >> (gdb) >> (gdb) >> (gdb) >> (gdb) >> (gdb) p a >> $1 = 0.10000000000000001 >> (gdb) p a+1 >> $2 = 1 >> (gdb) p a*10 >> $3 = 0 >> (gdb) p a*a >> $4 = 0 >> (gdb) p a+a >> $5 = 0 >> (gdb) p a+0 >> $6 = 0 >> (gdb) p mode >> $7 = 0x11ed0 "DEBUG1" >> (gdb) c >> Continuing. >> start >> a*b= 0.02 >> c*d= 0.02 >> end >> >> Program exited normally. >> (gdb) >> (3-2-2) -DDEBUG3 >> (gdb) run >> `/home/yoshimi/VVV/src/test_gdb/testrng' has changed; re-reading symbols. >> Breakpoint 1 at 0x10d80: file main.c, line 19. >> Starting program: /home/yoshimi/VVV/src/test_gdb/testrng >> >> Breakpoint 1, main () at main.c:19 >> (gdb) s >> (gdb) >> (gdb) >> (gdb) >> (gdb) >> (gdb) p a+1 >> $1 = 1 >> (gdb) p a*10 >> $2 = 0 >> (gdb) p c+1 >> $3 = 1.1000000014901161 >> (gdb) p c*10 >> $4 = 1.0000000149011612 >> (gdb) c >> Continuing. >> start >> a*b= 0.02 >> c*d= 0.02 >> end >> >> Program exited normally. >> (gdb) (4) Summary As the example above, the values defined as 'DOUBLE64' or 'FLOAT32' are uncorrectly evaluated in calculation. It is an annoying bug, when you want to check the values by calculation manually. As printing a data itself works, the value is correctly stored in the memory and gdb should know the type of it even if it is substituted by 'typedef'. I believe it is a bug in evaluating or parsing formula in print command. Sometimes you cannot avoid it when the 'typedef'ed floating point variable is one of the members of a structure. Sincerely yours, Takashi Yoshimi 2000.05.18