New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpp code gen bug in nim-glm #6455
Labels
Comments
Same issue in Arraymancer mratsim/Arraymancer#91. In Arraymancer, the codegen issue was introduced by replacing higher-order functions that accepts closures by templates that uses {.inject.} Edit: N_NIMCALL(void, slicerMut_5HNBiHajzTdmOUheqCgr2A)(tyObject_Tensor_8gG034a4DEBvD9ctN8nyxaw& t, tyObject_SteppedSlice_rJTlbLcKC9bpAJbFSrlwOrQ* slices, NI slicesLen_0, NI val$
tyObject_Tensor_8gG034a4DEBvD9ctN8nyxaw sliced;
tyObject_Tensor_8gG034a4DEBvD9ctN8nyxaw T1_;
memset((void*)(&sliced), 0, sizeof(sliced));
memset((void*)(&T1_), 0, sizeof(T1_));
unsafeSlicer_SRZrYFq46KhcUYobS9bdI9cg_2((&t), slices, slicesLen_0, (&T1_));
sliced.shape = T1_.shape;
sliced.strides = T1_.strides;
sliced.offset = T1_.offset;
sliced.data = T1_.data;
{
NI& old_val; // <------- here, needs initializer
old_val = (NI&)0; // <------- here, needs initializer
NI* data = dataArray_v3eUw6FwA4Vs9cV5O3TkzvQtest_init((&sliced));
{
if (!is_C_contiguous_dDfDc3pbZUoFoNv6AVz18Atest_init((&sliced))) goto LA5_;
{ {
NI i;
NI colontmp_;
NI T8_;
... |
Reproduced with a small test case import sequtils
import future
type CustomSeq[T] = object
data: seq[T]
iterator mitems[T](cs: var CustomSeq[T]): var T {.inline,noSideEffect.} =
for val in cs.data.mitems:
yield val
template map[T](cs: CustomSeq[T], op:untyped): untyped =
var dest = cs
for x {.inject.} in dest.mitems:
x = op
dest
let a = CustomSeq[int](data: toSeq(1..10))
let b = a.map(x * 2)
echo b Error:
There is no issue with the C backend |
Just tested it. It works now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/stavenko/nim-glm/blob/master/tests/quaternion.nim
The text was updated successfully, but these errors were encountered: