Opened 10 years ago

Closed 10 years ago

#2889 closed defect (fixed)

Function pointers loose their default values

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: 1.9.1
Component: MetaModelica Version: trunk
Keywords: Cc:

Description

Evaluating the test function below causes a segfault:

function FuncID11<IT1, OT1>
  input FuncType inFunc;
  output FuncType outFunc := inFunc;

  partial function FuncType
    input IT1 inArg1;
    output OT1 outArg1;
  end FuncType;
end FuncID11;

function f1
  input Real x;
  input Real y;
  output Real z := x + y;
end f1;

function test
  partial function pf
    input Real x;
    output Real z;
  end pf;

  output Real x;
protected
  pf mypf;
algorithm
  mypf := FuncID11(function f1(y = 3));
  x := mypf(2);
end test;

The reason is that outFunc in FuncID11 becomes a SimCode.FUNCTION_PTR, which doesn't have a field to store the default value in. A workaround in this case is to do the assignment in an algorithm section, but this obviously doesn't work for input default arguments.

Change History (4)

comment:1 by Martin Sjölund, 10 years ago

Milestone: Bootstrapping1.9.1
Resolution: fixed
Status: newclosed

Fixed in r22763.

comment:2 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: closedreopened

The test added to hudson seems to seg.fault. Worked fine on my machine. Will investigate.

comment:3 by Martin Sjölund, 10 years ago

My commit was reverted in r22769 ...

comment:4 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: reopenedclosed

Re-fixed in r22783.

Note: See TracTickets for help on using tickets.