Opened 14 years ago

Last modified 14 years ago

#1305 closed defect (fixed)

Codegen does not set the binding of a protected variable in a function if the binding is an array

Reported by: adrpo Owned by: adrpo
Priority: high Milestone:
Component: Simulation Code Generation Version: 1.6.0
Keywords: Cc: adrpo, adrpo

Description

Loading function:

function testRandom1
  input Integer seed_start[3] = {23,87,187};
  output Real x;
  protected
    Integer seed[3] = seed_start; // this is set to 0 and not to seed_start!
algorithm
  for i in 1:10 loop
   (x, seed) := random(seed);
   // Modelica.Utilities.Streams.print("x = " + String(x,significantDigits=16) + "\n");
  end for;
end testRandom1;

and call it with different values, gets you the same value:

testRandom1({5,6,13});
0.0592874602539062
testRandom1({6,7,2});
0.0592874602539062
testRandom1({33,21,17});
0.0592874602539062

This is because seed is not bound to seed_start.
This does not happen if the function evaluates via Cevalfunc,
but when we generate code for it, the seed array is always zero.

Change History (0)

Note: See TracTickets for help on using tickets.