Opened 13 years ago

Last modified 12 years ago

#1746 closed defect (fixed)

Inconsistent array access using indices

Reported by: mburisch Owned by: mburisch
Priority: high Milestone: 1.9.0
Component: Code Generation Version:
Keywords: Cc: mburisch

Description (last modified by Martin Sjölund)

Array access inside a function seems to be 0-based, whereas I think it should be 1-based. Furthermore it depends on wheter evaluation is during compile time (1-based) or runtime (0-based). Se the following example:

model Test2
  function func
    input Integer idx;
    output Integer value;
  protected
    constant Integer[4] values = {1, 2, 3, 4};
  algorithm
    value := values[idx];
  end func;

  parameter Integer idx = 1;
  parameter Integer p1 = func(1);    // = 1
  parameter Integer p2 = func(idx);  // = 2
end Test2;

Change History (2)

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

Thanks for the report. Fixed in r11922.

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

Cc: mburisch, → mburisch
Component: Code Generation
Description: modified (diff)
Milestone: 1.9.0
Note: See TracTickets for help on using tickets.