Opened 9 years ago

Last modified 9 years ago

#3420 closed defect

List.find() causes segmentation fault — at Version 2

Reported by: Jan Silar Owned by: Martin Sjölund
Priority: high Milestone: 1.9.3
Component: Code Generation Version: trunk
Keywords: Cc:

Description (last modified by Per Östlund)

When List.find is called and later fail() is called than the latter call causes segmentation fault.

To reproduce the problem add somewhere:

 _ := List.find({1,2,3,4}, findTestF);
  fail();

...

protected function findTestF
  input Integer inI;
  output Integer outI;
algorithm
  outI := match inI
    case 3
    then 9;
  end match;
end findTestF;

Change History (2)

comment:1 by Per Östlund, 9 years ago

Owner: changed from somebody to Martin Sjölund
Status: newassigned

Martin is working on this. Prefer using List functions that takes functions returning true or false instead of succeeding or failing though, it's more efficient since fail/matchcontinue costs more than checking a boolean. In this case we don't seem to have a specific List function that does the equivalent of List.find, but you could do e.g. someMapFunc(List.getMemberOnTrue({1, 2, 3, 4}, isThree)) (or just implement List.findOnTrue).

comment:2 by Per Östlund, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.