Skip to content

Commit 1986dce

Browse files
committed
Fix bug in memory access of cleartext fixed-point values with binary circuits.
1 parent a0c642d commit 1986dce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Compiler/GC/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,16 +1491,17 @@ class cbitfix(object):
14911491
malloc = staticmethod(lambda *args: cbits.malloc(*args))
14921492
n_elements = staticmethod(lambda: 1)
14931493
conv = staticmethod(lambda x: x)
1494-
load_mem = classmethod(lambda cls, *args: cls._new(cbits.load_mem(*args)))
1494+
load_mem = classmethod(lambda cls, *args: cls._new(
1495+
cbits.get_type(cls.k).load_mem(*args), adjust=False))
14951496
store_in_mem = lambda self, *args: self.v.store_in_mem(*args)
14961497
mem_size = staticmethod(lambda *args: 1)
14971498
size = 1
14981499
@classmethod
1499-
def _new(cls, value):
1500+
def _new(cls, value, adjust=True):
15001501
if isinstance(value, list):
15011502
return [cls._new(x) for x in value]
15021503
res = cls()
1503-
if cls.k < value.unit:
1504+
if cls.k < value.unit and adjust:
15041505
bits = value.bit_decompose(cls.k)
15051506
sign = bits[-1]
15061507
value += (sign << (cls.k)) * -1

0 commit comments

Comments
 (0)