-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-asmjsTarget: asm.js - http://asmjs.org/Target: asm.js - http://asmjs.org/O-emscriptenTarget: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!
Description
Running some tests this program is incorrect when run through emscripten currently:
fn main() {
println!("{}", 255u8.leading_zeros());
}
This program prints 232 when I'd expect 0. This may be due to the implementation in emscripten-core/emscripten#4544 which looks like:
function _llvm_ctlz_i8(x, isZeroUndef) {
x = x | 0;
isZeroUndef = isZeroUndef | 0;
return (Math_clz32(x) | 0) - 24 | 0;
}
(in the compiled JS at least)
x
coming in is -1
, so Math_clz32(x)
returns 0, and then chopping of 24 returns -24. When interpreted as a u8 that's 232 (what we see).
@kripken I'm not familiar with asmjs internals/representations, but is this a bug in the intrinsic? Or perhaps in our own representation of integers along the line? Or did I get unlucky with an LLVM mismatch or something?
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-asmjsTarget: asm.js - http://asmjs.org/Target: asm.js - http://asmjs.org/O-emscriptenTarget: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!