Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3594 closed defect (fixed)

Bitwise operators in MetaModelica are broken

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: critical Milestone: 1.9.4
Component: MetaModelica Version:
Keywords: Cc:

Description

The bitwise operators in MetaModelica seem to be completely broken, e.g.:

intBitLShift(1, 1))   // 1 << 1 = 2,   OMC says 2. ok!
intBitLShift(1, 2))   // 1 << 2 = 4,   OMC still says 2!
intBitLShift(32, 1))  // 32 << 1 = 64, OMC says 2^37!?
intBitRShift(1, 1))   // 1 >> 1 = 0,   OMC says 0. ok!
intBitRShift(2, 1))   // 2 >> 1 = 1,   OMC says 0.
intBitRShift(64, 5))  // 64 >> 5 = 2,  OMC says 0.
intBitOr(1, 2))       // 1 | 2 = 3,    OMC says 1.
intBitAnd(7, 4))      // 7 & 4 = 4,    OMC says 7.

The code generation just generates normal C operators for these, so I'm guessing the issue is due to some fun boxing/unboxing stuff. The operators are not actually used in the compiler at the moment, which would explain why noone's noticed before.

Attachments (1)

test.mos (463 bytes ) - added by Per Östlund 9 years ago.
Test script

Download all attachments as: .zip

Change History (5)

by Per Östlund, 9 years ago

Attachment: test.mos added

Test script

comment:1 by Per Östlund, 9 years ago

Resolution: fixed
Status: newclosed

Fixed in 881d9f6. It was just a typo in the code generator.

comment:2 by Dietmar Winkler, 9 years ago

Milestone: Future1.9.4

Sorting these closed tickets away from "Future". Since they were closed after the last 1.9.3 release, it's very likely that they should have been part of the 1.9.4 release.

comment:3 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.