Opened 12 years ago

Closed 10 years ago

#2030 closed defect (worksforme)

Array Slice Assignment not simulatable

Reported by: Jens Frenkel Owned by: Martin Sjölund
Priority: critical Milestone: 1.9.1
Component: Code Generation Version: trunk
Keywords: array slice assignment Cc: Willi Braun

Description

The following models is not simulatable because codegeneration/simulation runtime generates invalid code.

model Test
  Real A[5,2]={{1,2},{3,4},{5,6},{7,8},{9,10}};
  Real X1[5,2];
algorithm
  for i in 1:2 loop
    X1[:,i]:=A[:,i];
  end for;
end Test;

Code generation generates

    modelica_integer $Pi;
    for($Pi = (modelica_integer) 1; in_range_integer($Pi, tmp4, tmp6); $Pi += tmp5)
    {
      tmp3 = get_memory_state();
      array_alloc_scalar_real_array(&tmp0, 5, (modelica_real)(&$PA)[(((modelica_integer) 1)*2)+(((modelica_integer)$Pi))], (modelica_real)(&$PA)[(((modelica_integer) 2)*2)+(((modelica_integer)$Pi))], (modelica_real)(&$PA)[(((modelica_integer) 3)*2)+(((modelica_integer)$Pi))], (modelica_real)(&$PA)[(((modelica_integer) 4)*2)+(((modelica_integer)$Pi))], (modelica_real)(&$PA)[(((modelica_integer) 5)*2)+(((modelica_integer)$Pi))]);
      create_index_spec(&tmp1, 2, (1), (int*)0, 'W', (0), make_index_array(1, (int) (modelica_integer)$Pi), 'S');
      indexed_assign_real_array(&tmp0, &tmp2, &tmp1);
      copy_real_array_data_mem(&tmp2, &$PX1);
      restore_memory_state(tmp3);
    }

The problem is that tmp2.dim_size ist not set and "copy_real_array_data_mem" wrote in other memory than reserved for $PX1. Maybe indexed_assign_real_array should set tmp2.dim_size.

Change History (3)

comment:1 by Jens Frenkel, 12 years ago

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

Milestone: 1.9.02.0.0
Priority: blockercritical

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

Milestone: 2.0.01.9.1
Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.