public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13943] New: gdb does not correctly handle underflow in the "print" command
@ 2012-04-04 11:00 dpovey at gmail dot com
  0 siblings, 0 replies; only message in thread
From: dpovey at gmail dot com @ 2012-04-04 11:00 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-04 11:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04 11:00 [Bug c++/13943] New: gdb does not correctly handle underflow in the "print" command dpovey at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).