Repository: pyccel/pyccel (python)

Issue:
runtime inferred Negative numpy array slices do not translate well in C
### Describe the bug
When computing slices of numpy arrays with variable slices, translation is performed without negativity check.

### To Reproduce
```python
import numpy as np
from pyccel.decorators import allow_negative_index

@allow_negative_index('a')
def f(x : 'int'):
    a = np.array([1,2,3,4,5])
    b = a[-2 * x:-x]
    print(a[-x])
    print(b)

if __name__ == '__main__':
    f(1)
```

### Error details
```c
void f(int64_t x)
{
    array_int64_1d a = {0};
    array_int64_1d b = {0};
    int64_t* a_ptr;
    int64_t i;
    a_ptr = malloc(sizeof(int64_t) * (INT64_C(5)));
    a = (array_int64_1d)cspan_md_layout(c_ROWMAJOR, a_ptr, INT64_C(5));
    (*cspan_at(&a, INT64_C(0))) = INT64_C(1);
    (*cspan_at(&a, INT64_C(1))) = INT64_C(2);
    (*cspan_at(&a, INT64_C(2))) = INT64_C(3);
    (*cspan_at(&a, INT64_C(3))) = INT64_C(4);
    (*cspan_at(&a, INT64_C(4))) = INT64_C(5);
    b = cspan_slice(array_int64_1d, &a, {(-INT64_C(2)) * x < INT64_C(0) ? a.shape[INT64_C(0)] - (-INT64_C(2)) * x : (-INT64_C(2)) * x, -x < INT64_C(0) ? a.shape[INT64_C(0)] + x : -x});
    printf("%"PRId64"\n", (*cspan_at(&a, -x < INT64_C(0) ? INT64_C(5) - x : -x)));
    printf("[");
    for (i = INT64_C(0); i < b.shape[INT64_C(0)] - INT64_C(1); i += INT64_C(1))
    {
        printf("%"PRId64" ", (*cspan_at(&b, i)));
    }
    printf("%"PRId64"]\n", (*cspan_at(&b, b.shape[INT64_C(0)] - INT64_C(1))));
    free(a.data);
    a.data = NULL;
}
```
```bash
boo: pyccel/__pyccel__/STC/src/../include/stc/cspan.h:400: _cspan_slice: Assertion `(oshape[oi] > 0) & !((size_t)(shape[i]) < (size_t)(end))' failed.
[1]    16097 IOT instruction (core dumped)  ./boo
```
### Expected behavior
The _cspan_slice assertion should not fail.

### Language
C

### Additional context
Add any other context about the problem here.


Pull request:
Fix negative numbers in slice indices
Fix negative numbers in slice indices when translating to C. Fixes #2235 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 761ab8c7..abace433 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -156,6 +156,7 @@ All notable changes to this project will be documented in this file.
 -   #2285 : Reduce number of warnings in unit tests.
 -   #2295 : Fix wrapper handling of constant array arguments.
 -   #2097 : Fix printing of an empty list.
+-   #2235 : Fix negative numbers in slice indices when translating to C.
 
 ### Changed
 
diff --git a/pyccel/ast/utilities.py b/pyccel/ast/utilities.py
index 4013d617..5a7c15a0 100644
--- a/pyccel/ast/utilities.py
+++ b/pyccel/ast/utilities.py
@@ -353,7 +353,11 @@ def insert_index(expr, pos, index_var):
             if indices[pos].step is not None:
                 index_var = PyccelMul(index_var, indices[pos].step, simplify=True)
             if indices[pos].start is not None:
-                index_var = PyccelAdd(index_var, indices[pos].start, simplify=True)
+                if is_literal_integer(indices[pos].start) and int(indices[pos].start) < 0:
+                    index_var = PyccelAdd(PyccelAdd(base.shape[pos], indices[pos].start, simplify=True),
+                                          index_var, simplify=True)
+                else:
+                    index_var = PyccelAdd(index_var, indices[pos].start, simplify=True)
 
         # Update index
         indices[pos] = index_var
diff --git a/pyccel/codegen/printing/ccode.py b/pyccel/codegen/printing/ccode.py
index 8a2f073f..4751a789 100644
--- a/pyccel/codegen/printing/ccode.py
+++ b/pyccel/codegen/printing/ccode.py
@@ -1930,41 +1930,43 @@ class CCodePrinter(CodePrinter):
         Slice
             The new slice with processed arguments (start, stop, step).
         """
-        start = LiteralInteger(0) if _slice.start is None else _slice.start
-        stop = array_size if _slice.stop is None else _slice.stop
+        explicit_start = LiteralInteger(0) if _slice.start is None else _slice.start
+        explicit_stop = array_size if _slice.stop is None else _slice.stop
 
         # negative start and end in slice
-        if isinstance(start, PyccelUnarySub) and isinstance(start.args[0], LiteralInteger):
-            start = PyccelMinus(array_size, start.args[0], simplify = True)
-        elif allow_negative_index and not isinstance(start, (LiteralInteger, PyccelArrayShapeElement)):
-            start = IfTernaryOperator(PyccelLt(start, LiteralInteger(0)),
-                            PyccelMinus(array_size, start, simplify = True), start)
+        if isinstance(explicit_start, PyccelUnarySub) and isinstance(explicit_start.args[0], LiteralInteger):
+            start = PyccelMinus(array_size, explicit_start.args[0], simplify = True)
+        elif allow_negative_index and not isinstance(explicit_start, (LiteralInteger, PyccelArrayShapeElement)):
+            start = IfTernaryOperator(PyccelLt(explicit_start, LiteralInteger(0)),
+                            PyccelAdd(array_size, explicit_start, simplify = True), explicit_start)
         else:
             start = _slice.start
 
-        if isinstance(stop, PyccelUnarySub) and isinstance(stop.args[0], LiteralInteger):
-            stop = PyccelMinus(array_size, stop.args[0], simplify = True)
-        elif allow_negative_index and not isinstance(stop, (LiteralInteger, PyccelArrayShapeElement)):
-            stop = IfTernaryOperator(PyccelLt(stop, LiteralInteger(0)),
-                            PyccelMinus(array_size, stop, simplify = True), stop)
+        if isinstance(explicit_stop, PyccelUnarySub) and isinstance(explicit_stop.args[0], LiteralInteger):
+            stop = PyccelMinus(array_size, explicit_stop.args[0], simplify = True)
+        elif allow_negative_index and not isinstance(explicit_stop, (LiteralInteger, PyccelArrayShapeElement)):
+            stop = IfTernaryOperator(PyccelLt(explicit_stop, LiteralInteger(0)),
+                            PyccelAdd(array_size, explicit_stop, simplify = True), explicit_stop)
         else:
             stop = _slice.stop
 
         # steps in slices
-        step = _slice.step
+        explicit_step = _slice.step or LiteralInteger(1)
 
         # negative step in slice
-        if step and isinstance(step, PyccelUnarySub) and isinstance(step.args[0], LiteralInteger):
+        if isinstance(explicit_step, PyccelUnarySub) and isinstance(explicit_step.args[0], LiteralInteger):
             start = PyccelMinus(array_size, LiteralInteger(1), simplify = True) if _slice.start is None else start
             stop = LiteralInteger(0) if _slice.stop is None else stop
             raise NotImplementedError("Negative step not yet handled")
 
         # variable step in slice
-        elif step and allow_negative_index and step and not isinstance(step, LiteralInteger):
-            og_start = start
-            start = IfTernaryOperator(PyccelGt(step, LiteralInteger(0)), start, PyccelMinus(stop, LiteralInteger(1), simplify = True))
-            stop = IfTernaryOperator(PyccelGt(step, LiteralInteger(0)), stop, og_start)
+        elif allow_negative_index and not isinstance(explicit_step, LiteralInteger):
+            start = IfTernaryOperator(PyccelGt(explicit_step, LiteralInteger(0)), explicit_start,
+                                      PyccelMinus(explicit_stop, LiteralInteger(1), simplify = True))
+            stop = IfTernaryOperator(PyccelGt(explicit_step, LiteralInteger(0)), explicit_stop, explicit_start)
             raise NotImplementedError("Negative step not yet handled")
+        else:
+            step = _slice.step
 
         return Slice(start, stop, step)
 
diff --git a/pyccel/codegen/wrapper/c_to_python_wrapper.py b/pyccel/codegen/wrapper/c_to_python_wrapper.py
index dd8a07af..d0413a9b 100644
--- a/pyccel/codegen/wrapper/c_to_python_wrapper.py
+++ b/pyccel/codegen/wrapper/c_to_python_wrapper.py
@@ -2343,17 +2343,18 @@ class CToPythonWrapper(Wrapper):
             return {'body': body, 'args': [arg_var], 'default_init': default_body}
 
         arg_var = orig_var.clone(self.scope.get_new_name(orig_var.name), is_argument = False, is_optional=False,
-                                memory_handling='alias', new_class = Variable, is_const = False)
+                                memory_handling='alias', new_class = Variable, allows_negative_indexes = False,
+                                is_const = False)
         self.scope.insert_variable(arg_var)
         if orig_var.is_optional:
             sliced_arg_var = orig_var.clone(self.scope.get_new_name(orig_var.name), is_argument = False,
                                     is_optional=False, memory_handling='alias', new_class = Variable,
-                                    is_const = False)
+                                    allows_negative_indexes = False, is_const = False)
             self.scope.insert_variable(sliced_arg_var)
         else:
             sliced_arg_var = orig_var.clone(self.scope.get_expected_name(orig_var.name), is_argument = False,
                                     is_optional=False, memory_handling='alias', new_class = Variable,
-                                    is_const = False)
+                                    allows_negative_indexes = False, is_const = False)
             self.scope.insert_variable(sliced_arg_var, orig_var.name)
 
         original_size = tuple(PyccelMul(sh, st) for sh, st in zip(shape_elems, stride_elems))


Test patch:
diff --git a/tests/epyccel/test_arrays.py b/tests/epyccel/test_arrays.py
index 7595d0ac..3406e801 100644
--- a/tests/epyccel/test_arrays.py
+++ b/tests/epyccel/test_arrays.py
@@ -2428,13 +2428,6 @@ def test_array_1d_slice_9(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_1d_slice_10(language):
     a = arrays.a_1d
 
@@ -2444,13 +2437,6 @@ def test_array_1d_slice_10(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_1d_slice_11(language):
     a = arrays.a_1d
 
@@ -2460,13 +2446,6 @@ def test_array_1d_slice_11(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_1d_slice_12(language):
     a = arrays.a_1d
 
@@ -2639,13 +2618,6 @@ def test_array_2d_F_slice_20(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_F_slice_21(language):
     a = arrays.a_2d_f
 
@@ -2654,13 +2626,6 @@ def test_array_2d_F_slice_21(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_F_slice_22(language):
     a = arrays.a_2d_f
 
@@ -2669,13 +2634,6 @@ def test_array_2d_F_slice_22(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_F_slice_23(language):
     a = arrays.a_2d_f
 
@@ -2847,13 +2805,6 @@ def test_array_2d_C_slice_20(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_C_slice_21(language):
     a = arrays.a_2d_c
 
@@ -2862,13 +2813,6 @@ def test_array_2d_C_slice_21(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_C_slice_22(language):
     a = arrays.a_2d_c
 
@@ -2877,13 +2821,6 @@ def test_array_2d_C_slice_22(language):
     assert f1(a) == f2(a)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Array slicing does not work with negative variables in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_array_2d_C_slice_23(language):
     a = arrays.a_2d_c
 
@@ -2905,7 +2842,7 @@ def test_array_1d_slice_stride_1(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -2930,7 +2867,7 @@ def test_array_1d_slice_stride_3(language):
         pytest.param("fortran", marks = pytest.mark.fortran),
         pytest.param("python", marks = pytest.mark.python),
         pytest.param("c", marks = [
-            pytest.mark.xfail(reason="Negative strides in slices are not handled"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]
         )
     )
@@ -2953,7 +2890,7 @@ def test_array_1d_slice_stride_5(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -2976,7 +2913,7 @@ def test_array_1d_slice_stride_7(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -2999,7 +2936,7 @@ def test_array_1d_slice_stride_9(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3022,7 +2959,7 @@ def test_array_1d_slice_stride_11(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3045,7 +2982,7 @@ def test_array_1d_slice_stride_13(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3060,7 +2997,7 @@ def test_array_1d_slice_stride_14(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3083,7 +3020,7 @@ def test_array_1d_slice_stride_16(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3098,7 +3035,7 @@ def test_array_1d_slice_stride_17(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3121,7 +3058,7 @@ def test_array_1d_slice_stride_19(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3136,7 +3073,7 @@ def test_array_1d_slice_stride_20(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3161,7 +3098,7 @@ def test_array_1d_slice_stride_22(language):
         pytest.param("fortran", marks = pytest.mark.fortran),
         pytest.param("python", marks = pytest.mark.python),
         pytest.param("c", marks = [
-            pytest.mark.xfail(reason="Negative strides in slices are not handled"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]
         )
     )
@@ -3187,7 +3124,7 @@ def test_array_2d_F_slice_stride_1(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3202,7 +3139,7 @@ def test_array_2d_F_slice_stride_2(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3292,7 +3229,7 @@ def test_array_2d_F_slice_stride_9(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3307,7 +3244,7 @@ def test_array_2d_F_slice_stride_10(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3322,7 +3259,7 @@ def test_array_2d_F_slice_stride_11(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3337,7 +3274,7 @@ def test_array_2d_F_slice_stride_12(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3352,7 +3289,7 @@ def test_array_2d_F_slice_stride_13(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3367,7 +3304,7 @@ def test_array_2d_F_slice_stride_14(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3382,7 +3319,7 @@ def test_array_2d_F_slice_stride_15(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3397,7 +3334,7 @@ def test_array_2d_F_slice_stride_16(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3412,7 +3349,7 @@ def test_array_2d_F_slice_stride_17(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3427,7 +3364,7 @@ def test_array_2d_F_slice_stride_18(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3442,7 +3379,7 @@ def test_array_2d_F_slice_stride_19(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3457,7 +3394,7 @@ def test_array_2d_F_slice_stride_20(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3472,7 +3409,7 @@ def test_array_2d_F_slice_stride_21(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3487,7 +3424,7 @@ def test_array_2d_F_slice_stride_22(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3513,7 +3450,7 @@ def test_array_2d_C_slice_stride_1(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3528,7 +3465,7 @@ def test_array_2d_C_slice_stride_2(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3551,7 +3488,7 @@ def test_array_2d_C_slice_stride_4(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3574,7 +3511,7 @@ def test_array_2d_C_slice_stride_6(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3597,7 +3534,7 @@ def test_array_2d_C_slice_stride_8(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3612,7 +3549,7 @@ def test_array_2d_C_slice_stride_9(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3627,7 +3564,7 @@ def test_array_2d_C_slice_stride_10(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3642,7 +3579,7 @@ def test_array_2d_C_slice_stride_11(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3657,7 +3594,7 @@ def test_array_2d_C_slice_stride_12(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3672,7 +3609,7 @@ def test_array_2d_C_slice_stride_13(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3687,7 +3624,7 @@ def test_array_2d_C_slice_stride_14(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3702,7 +3639,7 @@ def test_array_2d_C_slice_stride_15(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3717,7 +3654,7 @@ def test_array_2d_C_slice_stride_16(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3732,7 +3669,7 @@ def test_array_2d_C_slice_stride_17(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3747,7 +3684,7 @@ def test_array_2d_C_slice_stride_18(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3762,7 +3699,7 @@ def test_array_2d_C_slice_stride_19(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3777,7 +3714,7 @@ def test_array_2d_C_slice_stride_20(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3792,7 +3729,7 @@ def test_array_2d_C_slice_stride_21(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3807,7 +3744,7 @@ def test_array_2d_C_slice_stride_22(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3938,13 +3875,6 @@ def test_arrs_2d_different_shapes_0(language):
     check_array_equal(f1(), f2())
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="Negative start of range does not work in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_arrs_1d_negative_index_1(language):
     f1 = arrays.arrs_1d_negative_index_1
     f2 = epyccel(f1, language = language)
@@ -3971,7 +3901,7 @@ def test_arrs_1d_int64_index(language):
 
 @pytest.mark.parametrize( 'language', [
         pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
+            pytest.mark.skip(reason="Negative strides in slices are not handled in C. See #1311"),
             pytest.mark.c]),
         pytest.param("fortran", marks = pytest.mark.fortran)
     ]
@@ -3988,13 +3918,6 @@ def test_arrs_1d_negative_step_positive_step(language):
     assert np.allclose(f1(), f2(), rtol=RTOL, atol=ATOL)
 
 
-@pytest.mark.parametrize( 'language', [
-        pytest.param("c", marks = [
-            pytest.mark.skip(reason="negative step does not work in c. See #1311"),
-            pytest.mark.c]),
-        pytest.param("fortran", marks = pytest.mark.fortran)
-    ]
-)
 def test_arrs_2d_negative_index(language):
     f1 = arrays.arrs_2d_negative_index
     f2 = epyccel(f1, language = language)