------- Additional Comments From rmathew at gcc dot gnu dot org  2005-06-18 
05:14 -------
(In reply to comment #2)
> Subject: Re:  Divide_1 test case hangs
> 
> >   -2147483648
> >   -2147483648
> >   0
> >   0
> >   [...]
> > 
> > Note that the values are totally off.
> > 
> This looks somewhat familiar.  Could you try testing with
> -fno-tree-vrp?

Doesn't help. In a weird twist, I actually get the correct
result if I use any optimisation level (-O{1,2,3})! (That,
BTW, explains why the corresponding -O3 testcase didn't fail.)

When I compile this testcase manually and run it (at -O0),
I get:

1219954614
-2147483648
1174405120
12019755
0
Aborted

Under the debugger:
----------------------------- 8< -----------------------------
(gdb) r
Starting program: /home/rmathew/src/tmp/a.out
[Thread debugging using libthread_db enabled]
[New Thread -1225922896 (LWP 28945)]
[New Thread -1226114128 (LWP 28948)]

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread -1225922896 (LWP 28945)]
0x08048bc4 in Divide_1.probe_1() ([EMAIL PROTECTED]) at Divide_1.java:11
11            int c = a/b;
Current language:  auto; currently java
(gdb) l
6
7         void probe_1 ()
8         {
9            try {
10            int a = Integer.parseInt ("-80000000", 16);
11            int c = a/b;
12            System.out.println (c);
13          } catch (Exception _) {
14            System.out.println (_);
15          }
(gdb) c
Continuing.
1488390214
-2147483648

Program received signal SIGFPE, Arithmetic exception.
0x08048dd3 in Divide_1.probe_1() ([EMAIL PROTECTED]) at Divide_1.java:27
27            int c = a%b;
(gdb) l
22            System.out.println (_);
23          }
24
25          try {
26            int a = Integer.parseInt ("-80000000", 16);
27            int c = a%b;
28            System.out.println (c);
29          } catch (Exception _) {
30            System.out.println (_);
31          }
(gdb) c
Continuing.
1174405120

Program received signal SIGFPE, Arithmetic exception.
0x08048eed in Divide_1.probe_1() ([EMAIL PROTECTED]) at Divide_1.java:35
35            int c = a%b1;
(gdb) l
30            System.out.println (_);
31          }
32
33          try {
34            int a = Integer.parseInt ("-80000000", 16);
35            int c = a%b1;
36            System.out.println (c);
37          } catch (Exception _) {
38            System.out.println (_);
39          }
(gdb) c
Continuing.
12019899
0

Program received signal SIGFPE, Arithmetic exception.
0x0804912a in Divide_1.probe_1() ([EMAIL PROTECTED]) at Divide_1.java:52
52            int c = a/b;
(gdb) l
47          }
48
49          try {
50            int a = Integer.parseInt ("8000", 16);
51            int b = Integer.parseInt ("0", 16);
52            int c = a/b;
53            System.out.println (c);
54          } catch (Exception _) {
55            System.out.println (_);
56          }
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
uw_frame_state_for (context=0xbfffe6b8, fs=0xbfffe5f8) at linux-unwind.h:125
125       if (*(unsigned short *)(pc+0) == 0xb858
(gdb) p pc
No symbol "pc" in current context.
(gdb) p context->ra
$1 = (void *) 0x62f
(gdb) p *context
$2 = {reg = {0xbffff01c, 0xbffff018, 0xbffff014, 0xbffff4b1, 0x0, 0xbffff008,
    0xbffff004, 0xbffff000, 0xbffff4b5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    0x0, 0x0}, cfa = 0xbffff4b9, ra = 0x62f, lsda = 0x0, bases = {tbase = 0x0,
    dbase = 0x804bc18, func = 0x8048b86}, args_size = 0}
(gdb) bt
#0  uw_frame_state_for (context=0xbfffe6b8, fs=0xbfffe5f8)
    at linux-unwind.h:125
#1  0xb7fe5632 in _Unwind_Backtrace (
    trace=0xb765d920 <_Jv_StackTrace::UnwindTraceFn(_Unwind_Context*, void*)>,
    trace_argument=0xbfffef30) at unwind.inc:293
#2  0xb765dac0 in _Jv_StackTrace::GetStackTrace ()
    at /extra/src/gcc/gcc-20050618/libjava/stacktrace.cc:159
#3  0xb768e29c in java::lang::VMThrowable::fillInStackTrace ()
    at /extra/src/gcc/gcc-20050618/libjava/java/lang/natVMThrowable.cc:33
#4  0xb7871a52 in java.lang.Throwable.fillInStackTrace() (this=0x4f858)
    at Throwable.java:498
#5  0xb7867532 in java.lang.Throwable.Throwable(java.lang.String) (
    this=0x4f858, message=0x62f) at Throwable.java:159
#6  0xb7869f53 in java.lang.Exception.Exception(java.lang.String) (this=0x62f,
    s=0x62f) at Exception.java:77
#7  0xb7869fe3 in java.lang.RuntimeException.RuntimeException(java.lang.String)
    (this=0x62f, s=0x62f) at RuntimeException.java:75
#8  0xb786c273 in
java.lang.ArithmeticException.ArithmeticException(java.lang.String) (this=0x62f,
s=0x62f) at ArithmeticException.java:74
#9  0xb7650cde in catch_fpe (_dummy=8)
    at /extra/src/gcc/gcc-20050618/libjava/prims.cc:166
#10 <signal handler called>
#11 0x0804912c in Divide_1.probe_1() (this=0x1e0004af) at Divide_1.java:52
---Type <return> to continue, or q <return> to quit---
#12 0x0000062f in ?? ()
#13 0x1e0004af in ?? ()
#14 0x000804a6 in ?? ()
#15 0x940004af in ?? ()
#16 0x08b7d3fa in ?? ()
#17 0x6dbffff5 in ?? ()
#18 0x00b78755 in ?? ()
#19 0x00b7e202 in ?? ()

[...and so on for 733 frames after which GDB 6.3 barfs out.]
----------------------------- 8< -----------------------------

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22084

Reply via email to