#19110: QQ(0)^-1 raises SIGFPE (which is caught)
------------------------------------+------------------------
       Reporter:  dkrenn            |        Owner:
           Type:  defect            |       Status:  new
       Priority:  critical          |    Milestone:  sage-6.9
      Component:  basic arithmetic  |   Resolution:
       Keywords:                    |    Merged in:
        Authors:                    |    Reviewers:
Report Upstream:  N/A               |  Work issues:
         Branch:                    |       Commit:
   Dependencies:                    |     Stopgaps:
------------------------------------+------------------------

Comment (by behackl):

 What about something like the following?

 {{{#!diff
 --- a/src/sage/rings/rational.pyx
 +++ b/src/sage/rings/rational.pyx
 @@ -2397,9 +2397,8 @@ cdef class
 Rational(sage.structure.element.FieldElement):
              mpz_pow_ui(mpq_numref(x.value), mpq_numref(_self.value), -nn)
              mpz_pow_ui(mpq_denref(x.value), mpq_denref(_self.value), -nn)
              # mpz_swap(mpq_numref(x.value), mpq_denref(x.value)) # still
 a segfault
 -            mpq_inv(x.value, x.value)
              sig_off()
 -            return x
 +            return ~x
          elif nn > 0:
              sig_on()
              mpz_pow_ui(mpq_numref(x.value), mpq_numref(_self.value), nn)

 }}}

 Basically, thats similar to what happens in `rings/integer.pyx` (I think).
 With these changes, I have
 {{{
 sage: QQ(0)^(-1)
 Traceback (most recent call last):
 ...
 ZeroDivisionError: rational division by zero
 }}}
 ... and all doctests in `rings/rational.pyx` pass as well. Any thoughts?

--
Ticket URL: <http://trac.sagemath.org/ticket/19110#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to