#2814 closed defect (duplicate)
Matching in for-loop overwrites iterator and causes segfault
Reported by: | Per Östlund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | MetaModelica | Version: | trunk |
Keywords: | Cc: |
Description
The following function segfaults:
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:
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.
Change History (2)
comment:1 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 10 years ago
Milestone: | Bootstrapping |
---|
Note:
See TracTickets
for help on using tickets.
Duplicate of #2813