Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Array initialization in Function fails

Array initialization in Function fails

A trivial example code to illustrate this.

Code:


model tryme
Real y ;

equation
   y = myfun(3.4) * y + 2 ;

end tryme;

function myfun
input Real x ;
output Real y ;

//  protected Real  z[3 ]= {1,2,3} ;  // This Falis (why ??)
    protected  Real  z[3] ;                  // Works

algorithm
  z[1] := x ;
  y    := 2 * z[1] ;
end myfun;


Re: Array initialization in Function fails

Bug reports go here: https://trac.openmodelica.org/OpenModelica/newticket. There is a segmentation fault in the model because it directly uses a constant data segment instead of copying it.

There are 0 guests and 0 other users also viewing this topic
You are here: