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: Martin Sjölund
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 by Adrian Pop, 3 years ago

Component: MetaModelicaRun-time
Milestone: 1.19.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.