﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2814	Matching in for-loop overwrites iterator and causes segfault	Per Östlund	Martin Sjölund	"The following function segfaults:
{{{#!mo
function test
protected
  list<Option<Integer>> l := {SOME(1), SOME(2)};
  Integer i;
algorithm
  for e in l loop
    SOME(i) := e;
  end for;
end test;
}}}
The cause seems to be because the C code for the for-loop becomes:
{{{#!c
for (tmpMeta[1] = _l; !listEmpty(tmpMeta[1]); tmpMeta[1]=listRest(tmpMeta[1]))
{
  _e = listFirst(tmpMeta[1]);
  tmpMeta[0] = _e;
  if (optionNone(tmpMeta[0])) MMC_THROW_INTERNAL();
  tmpMeta[1] = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(tmpMeta[0]), 1));
  tmp1 = mmc_unbox_integer(tmpMeta[1]);
  _i = tmp1;
}
}}}
I.e. tmpMeta[1], the iterator, gets overwritten by the matching."	defect	closed	high		MetaModelica	trunk	duplicate		
