Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3134 closed defect (fixed)

Compilation failure for functions returning two dimensional arrays

Reported by: crupp@… Owned by: Mahder Alemseged Gebremedhin
Priority: high Milestone: 1.9.4
Component: Code Generation Version: trunk
Keywords: Cc: Mahder Alemseged Gebremedhin

Description

The following model fails at compile time using r24377. It works using r23420. It seems to be caused by functions returning multidimensional arrays.

loadString("
model arrayFuncBug
  parameter Real a = 1;
  Real arr[3, 3];
equation
  arr = func(a = a);
end arrayFuncBug;

function func
  input Real a = 0.01;
  output Real arr[3, 3];
algorithm
  arr := diagonal({a ^ 2, a ^ 3, a ^ 4});
end func;
");

buildModel(arrayFuncBug);

The log file contains:

arrayFuncBug_functions.c: In function 'omc_func':
arrayFuncBug_functions.c:24: error: incompatible type for argument 3 of 'array_alloc_real_array'
C:/OpenModelica1.9.2Nightly//include/omc/c/util/real_array.h:144: note: expected 'real_array_t' but argument is of type 'modelica_real'
arrayFuncBug_functions.c:26: error: incompatible type for argument 3 of 'array_alloc_real_array'
C:/OpenModelica1.9.2Nightly//include/omc/c/util/real_array.h:144: note: expected 'real_array_t' but argument is of type 'double'
arrayFuncBug_functions.c:29: error: incompatible type for argument 3 of 'array_alloc_real_array'
C:/OpenModelica1.9.2Nightly//include/omc/c/util/real_array.h:144: note: expected 'real_array_t' but argument is of type 'double'

Change History (7)

comment:1 by Lennart Ochel, 10 years ago

Component: UnknownCode Generation
Owner: changed from somebody to Lennart Ochel

comment:2 by Lennart Ochel, 10 years ago

Cc: Mahder Alemseged Gebremedhin added
Owner: changed from Lennart Ochel to somebody
Status: newassigned

comment:3 by Mahder Alemseged Gebremedhin, 10 years ago

Owner: changed from somebody to Mahder Alemseged Gebremedhin
Status: assignedaccepted

comment:4 by crupp@…, 10 years ago

Just to let you know, this bug seems to be related to the diagonal function. I've since found that the issue disappears when the matrix is hard-coded.

comment:5 by Mahder Alemseged Gebremedhin, 10 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r2726. Yes, the issue was with how diagonal was handled in simplification. It created unnecessary problems for code generation.

comment:6 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

comment:7 by Martin Sjölund, 7 years ago

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.