umka-lang icon indicating copy to clipboard operation
umka-lang copied to clipboard

`int` overflow not detected

Open vtereshkov opened this issue 1 year ago • 1 comments

fn main() {
    var x: int = 9483412322824321334
    printf("%v", x)   // -8963331750885230282
}
fn main() {
    var x: uint = -1
    printf("%v", x)   // 18446744073709551615
}
fn main() {
    x := false ? 0 : 9483412322824321334
    printf("%v", x)   // -8963331750885230282
}

vtereshkov avatar Aug 06 '24 20:08 vtereshkov

Can this be detected at compile time? If operations like addition and subtraction e.t.c. are the only means of getting the overflow at runtime.

ske2004 avatar Aug 07 '24 19:08 ske2004