Skip to content

Commit 21e9019

Browse files
committed
Use volatile for result and arg_list in GapElement to prevent optimization issues
1 parent de8b7ad commit 21e9019

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/sage/libs/gap/element.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ cdef class GapElement(RingElement):
984984
GAPError: Error, no method found!
985985
Error, no 1st choice method found for `+' on 2 arguments
986986
"""
987-
cdef Obj result
987+
cdef volatile Obj result
988988
try:
989989
sig_GAP_Enter()
990990
sig_on()
@@ -1012,7 +1012,7 @@ cdef class GapElement(RingElement):
10121012
...
10131013
GAPError: Error, no method found! ...
10141014
"""
1015-
cdef Obj result
1015+
cdef volatile Obj result
10161016
try:
10171017
sig_GAP_Enter()
10181018
sig_on()
@@ -1041,7 +1041,7 @@ cdef class GapElement(RingElement):
10411041
GAPError: Error, no method found!
10421042
Error, no 1st choice method found for `*' on 2 arguments
10431043
"""
1044-
cdef Obj result
1044+
cdef volatile Obj result
10451045
try:
10461046
sig_GAP_Enter()
10471047
sig_on()
@@ -1075,7 +1075,7 @@ cdef class GapElement(RingElement):
10751075
...
10761076
GAPError: Error, Rational operations: <divisor> must not be zero
10771077
"""
1078-
cdef Obj result
1078+
cdef volatile Obj result
10791079
try:
10801080
sig_GAP_Enter()
10811081
sig_on()
@@ -1102,7 +1102,7 @@ cdef class GapElement(RingElement):
11021102
GAPError: Error, no method found!
11031103
Error, no 1st choice method found for `mod' on 2 arguments
11041104
"""
1105-
cdef Obj result
1105+
cdef volatile Obj result
11061106
try:
11071107
sig_GAP_Enter()
11081108
sig_on()
@@ -1150,6 +1150,7 @@ cdef class GapElement(RingElement):
11501150
GAPError: Error, no method found! Error, no 1st choice
11511151
method found for `InverseMutable' on 1 arguments
11521152
"""
1153+
cdef volatile Obj result
11531154
try:
11541155
sig_GAP_Enter()
11551156
sig_on()
@@ -2484,24 +2485,23 @@ cdef class GapElement_Function(GapElement):
24842485
sage: libgap.Sum(rnd)
24852486
6
24862487
2487-
sage: from sage.libs.gap.util import GAPError
24882488
sage: for i in range(100):
24892489
....: rnd = [ randint(-10,10) for i in range(randint(0,7)) ]
24902490
....: # compute the sum in GAP
24912491
....: _ = libgap.Sum(rnd)
24922492
....: try:
24932493
....: libgap.Sum(*rnd)
2494-
....: print('This should have triggered a GAPError')
2494+
....: print('This should have triggered a ValueError')
24952495
....: print('because Sum needs a list as argument')
2496-
....: except GAPError:
2496+
....: except ValueError:
24972497
....: pass
24982498
24992499
sage: libgap_exec = libgap.eval("Exec")
25002500
sage: libgap_exec('echo hello from the shell')
25012501
hello from the shell
25022502
"""
2503-
cdef Obj result = NULL
2504-
cdef Obj arg_list
2503+
cdef volatile Obj result = NULL
2504+
cdef volatile Obj arg_list
25052505
cdef int n = len(args)
25062506
cdef volatile Obj v2
25072507

0 commit comments

Comments
 (0)