Opened 4 years ago

Closed 3 years ago

#6353 closed defect (fixed)

Wrong Integer check and calculations in the 64bit Software.

Reported by: jens.schoenbohm@… Owned by: sjoelund.se
Priority: high Milestone: 1.19.0
Component: Run-time Version: 1.16.2
Keywords: Cc:

Description

I tried to run the following code:

function test1
  protected
    Integer z = 0;
  algorithm
 
  z := 2147483648; // 2^31
  print(String(z) + "\n");
end test1;

I got the following error:

[D:/basic_datatypes.mo:34:8-34:18:writable] Warning: OpenModelica (64-bit) only supports 63-bit signed integers! Transforming: 2147483648 into a real
[D:/basic_datatypes.mo:49:8-49:18:writable] Warning: OpenModelica (64-bit) only supports 63-bit signed integers! Transforming: 2147483648 into a real
[D:/basic_datatypes.mo:49:3-49:18:writable] Error: Type mismatch in assignment in z := 2147483648.0 of Integer := Real
[D:/basic_datatypes.mo:49:3-49:18:writable] Error: Type mismatch in pattern z
expression type:
  Real
pattern type:
  Integer

I also get some funny result with slightly different code:

function test1
  protected
    Integer z = 0;
  algorithm
 
  z := 2147483647; // 2^31  - 1 largest 32bit int
  z := z + 1;
  print(String(z) + "\n");
end test1;
Warning: OpenModelica (64-bit) only supports 63-bit signed integers! 
Transforming: 2147483648 into a real -2147483648

Change History (1)

comment:1 Changed 3 years ago by adrpo

  • Component changed from MetaModelica to Run-time
  • Milestone set to 1.19.0
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.