#64 Remainder bug testcase does not crash on SIGFPE

open
nobody
5
2014-06-05
2011-11-09
LRN
No

>c:\mingw64\bin\gdb.exe --args remaindertest2.exe
GNU gdb (GDB) 7.3.50.20111027-cvs
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-w64-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from remaindertest2.exe...done.
(gdb) start
Temporary breakpoint 1 at 0x402c50: file remaindertest.cpp, line 65.
Starting program: remaindertest2.exe
[New Thread 13556.0x24c0]

Temporary breakpoint 1, main (argc=1, argv=0x7b1fd0) at remaindertest.cpp:65
65 int main(int argc, char** argv) {
(gdb) s
__main () at ../../../build/mingw/mingw-w64-crt/crt/gccmain.c:55
55 ../../../build/mingw/mingw-w64-crt/crt/gccmain.c: No such file or directory.
in ../../../build/mingw/mingw-w64-crt/crt/gccmain.c
(gdb)
main (argc=1, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
minus_one (n=1) at remaindertest.cpp:57
57 return (n+1)*(n-1)-n*n;
(gdb)
main (argc=1, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
p (y=-1, x=-2147483648) at remaindertest.cpp:61
61 int z = x % y;
(gdb)
main (argc=<optimized out>, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
minus_one (n=<optimized out>) at remaindertest.cpp:57
57 return (n+1)*(n-1)-n*n;
(gdb)
main (argc=<optimized out>, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
p (y=<optimized out>, x=-2147483648) at remaindertest.cpp:61
61 int z = x % y;
(gdb)

Program received signal SIGFPE, Arithmetic exception.
main (argc=<optimized out>, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
p (y=<optimized out>, x=-2147483648) at remaindertest.cpp:61
61 int z = x % y;
(gdb)

Program received signal SIGFPE, Arithmetic exception.
main (argc=<optimized out>, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)
(gdb)
p (y=<optimized out>, x=-2147483648) at remaindertest.cpp:61
61 int z = x % y;
(gdb)

Program received signal SIGFPE, Arithmetic exception.
main (argc=<optimized out>, argv=<optimized out>) at remaindertest.cpp:66
66 if (p(INT_MIN, minus_one(argc)) != 0)

When run without gdb it simply loops forever.

remaindertest.cpp is attached. Compile like this (this is how PPL does it):
x86_64-w64-mingw32-g++ -o remaindertest2.exe -g -O2 -frounding-math -O3 -g -pipe remaindertest.cpp

Discussion

  • LRN
    LRN
    2011-11-09

    remainder bug testcase

     
    Attachments
  • Ozkan Sezer
    Ozkan Sezer
    2014-06-05

    Status?