Open
Description
I was testing pointers in lpython
and used the following python code:
from ltypes import c_p_pointer, CPtr, pointer, i16, Pointer
def f():
yq: CPtr
yptr1: Pointer[i16[:]]
y: i16[2]
y[0] = 1
y[1] = 2
yptr1 = pointer(y)
# This works
print(yptr1[0], yptr1[1])
assert yptr1[0] == 1
assert yptr1[1] == 2
c_p_pointer(yq, yptr1)
# Shouldn't this work the same way as earlier?
print(yptr1[0], yptr1[1])
f()
Running this I get:
% lpython expr.py && ./a.out
1 2
zsh: segmentation fault ./a.out