Opened 4 years ago
Closed 3 years ago
#6353 closed defect (fixed)
Wrong Integer check and calculations in the 64bit Software.
Reported by: | 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 , 3 years ago
Component: | MetaModelica → Run-time |
---|---|
Milestone: | → 1.19.0 |
Resolution: | → fixed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Fixed in https://github.com/OpenModelica/OpenModelica/pull/8691.