You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So it needs a fix in the LLVM backend, and the fix basically requires keeping the value between [0, 2**(kind*8)). This should be handled at every assignment of unsigned integers and also while initializing. We need not worry about C backend as it will handle the same by itself.
This also needs some more fixes in LLVM because right now we treat i8 the same as u8 while i8 is unable to store 255. So we need to fix this by:
LLVM treats u8 and i8 the same. It's the same LLVM type. The u8(255) is exactly the same bit representation as i8(-1). So I think the only fix we have to do is in the visit_Print() to treat the u8 correctly.
The example you posted doesn't work: #1898. But assuming it "works", for now I would not allow unsigned integers in empty. So empty(siz) should give an error message in AST->ASR as well as in verify() that unsigned integer is not supported. In ASR this ends up being part of the "dimensions" and we should enforce in verify() that only signed integers are allowed. I made this #1899.
Activity
Smit-create commentedon Jun 13, 2023
So it needs a fix in the LLVM backend, and the fix basically requires keeping the value between
[0, 2**(kind*8)). This should be handled at every assignment of unsigned integers and also while initializing. We need not worry aboutCbackend as it will handle the same by itself.This also needs some more fixes in LLVM because right now we treat
i8the same asu8whilei8is unable to store 255. So we need to fix this by:certik commentedon Jun 13, 2023
LLVM treats u8 and i8 the same. It's the same LLVM type. The u8(255) is exactly the same bit representation as i8(-1). So I think the only fix we have to do is in the visit_Print() to treat the u8 correctly.
Print unsigned ints correctly
Smit-create commentedon Jun 13, 2023
The fix I was suggesting not just only applies to print. If we fix just print there can be many other failures for the same reason. See the following:
This fails in LLVM but not in C because in LLVM
sizis-1.certik commentedon Jun 13, 2023
The example you posted doesn't work: #1898. But assuming it "works", for now I would not allow unsigned integers in
empty. Soempty(siz)should give an error message in AST->ASR as well as in verify() that unsigned integer is not supported. In ASR this ends up being part of the "dimensions" and we should enforce in verify() that only signed integers are allowed. I made this #1899.