Ticket #229 (closed defect: fixed)
Cython % operator on cdef int has C semantics, not Python semantics
| Reported by: | cwitty | Owned by: | robertwb |
|---|---|---|---|
| Priority: | blocker | Milestone: | 0.12 |
| Component: | Code Generation | Keywords: | |
| Cc: |
Description
That is,
cdef int a = -1 cdef int b = 16 a % b
gives -1, where Python would give 15.
This bit a new Sage developer, who was using the result as an index into a C array and got a segfault by indexing off the beginning.
I'm not sure whether this should be changed, but if not, it should be prominently documented; I couldn't find any mention in the documentation (but maybe I didn't look in the right place?).
Change History
Note: See
TracTickets for help on using
tickets.
