This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13943] New: gdb does not correctly handle underflow in the"print" command


http://sourceware.org/bugzilla/show_bug.cgi?id=13943

             Bug #: 13943
           Summary: gdb does not correctly handle underflow in the "print"
                    command
           Product: gdb
           Version: 7.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dpovey@gmail.com
    Classification: Unclassified


If a and b are doubles, and a / b underflows to zero, gdb "print" will wrap
around the exponent to make a very large value.  Example below.

a09:s3: cat foo.cc
#include <cstdlib>

main() {
  double a = 9.8813129168249309e-323, b = 1000;
  abort();
}

a09:s3: g++ -g foo.cc -o foo
a09:s3: gdb foo
GNU gdb (GDB) 7.3-debian
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from
/export/proceedings/dpovey_temp/kaldi-trunk/egs/rm/s3/foo...done.
(gdb) r

Starting program: /export/proceedings/dpovey_temp/kaldi-trunk/egs/rm/s3/foo

Program received signal SIGABRT, Aborted.
0x00007ffff72ef405 in *__GI_raise (sig=<optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) up
#1  0x00007ffff72f2680 in *__GI_abort () at abort.c:92
92  abort.c: No such file or directory.
    in abort.c
(gdb) list
87  in abort.c
(gdb) up
#2  0x0000000000400568 in main () at foo.cc:5
5     abort();
(gdb) list
1   #include <cstdlib>
2
3   main() {
4     double a = 9.8813129168249309e-323, b = 1000;
5     abort();
6   }
7
(gdb) p a / b
$2 = -3.1933444952555512e+291  <-------------- HERE IS THE BUG.  Should be
small
(gdb) quit

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]