@guvectorize with c-contiguous signature causes assertion error

Hello,

if I make the types in the signature of my @guvectorize procedure c-ontiguous, compilation fails very early with a strange AssertionError. Here is a a minimal example:

@guvectorize([void(float32[::1], float32[::1])], '(four)->(four)')
def foo(x, out):
    assert x.shape[-1] == 4
    for i in literal_unroll(range(4)):
        out[i] = x[i]


@jit([float32[:, ::1](float32[:, ::1])])
def bar(xs):
    out = numpy.empty_like(xs)
    foo(xs, out)
    return out


print(bar(numpy.arange(24).astype(numpy.float32).reshape(6, 4)))

Lowering crashes with this:

File "/opt/miniconda3/envs/video/lib/python3.11/site-packages/numba/np/arrayobj.py", line 6460, in array_to_array
    assert fromty.mutable != toty.mutable or toty.layout == 'A'
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

There are two ways I can work around this:

  1. I replace ::1 by : in the @guvectorize decorator (but not in the @jit dectorator).
  2. I hack the numba code in arrayobj.py, simply deleting the assert statement.

In both cases, the code runs just fine afterwards.

I have two questions:

  1. Am I observing a bug here, or am I doing something wrong?
  2. Is it even desirable to use ::1 in the @guvectorize decorator? I have been experimenting and I believe that it reduces the temporal overhead for calling my GUFunc, but I am not sure of this observation yet. So I would like to know whether c-contiguousness can have an impact on speed (and on loop vectorization) at all.

guvectorize is not specifically designed to work with contiguous arrays for core dimensions, as higher-dimensional arrays cannot be contiguous along multiple axes simultaneously. Using the axis parameter in this context could lead to incorrect results. The devs do not explicitly prevent the use of contiguous arrays as signatures (yet), but it is probably not recommended.