Closed juj closed 4 years ago
This is a known issue: in asm.js compatibility mode, we add extra math operations for such casts, since they are hard to do in js. Here we have
$2 = +Math_abs($0) >= 1.0 ? $0 > 0.0 ? (~~+Math_min(+Math_floor($0 / 4294967296.0), 4294967295.0)) >>> 0 : ~~+Math_ceil(($0 - +(~~$0 >>> 0)) / 4294967296.0) >>> 0 : 0; //@line 12 "a.cpp"
And some of those intermediate ops can trap in wasm. Setting the trap mode to clamp avoids it.
I admit this is confusing, but not sure what else we can do. It's a downside of setting the default trap mode to allow/fast.
This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
a.cpp
:em++ a.cpp -o a.html -s WASM=1
works ok as expected.However, building with
em++ a.cpp -o a.html -s WASM=1 -s OUTLINING_LIMIT=10000
orem++ a.cpp -o a.html -s WASM=1 -s BINARYEN_METHOD=\"native-wasm,asmjs\"
fails with
exception thrown: RuntimeError: integer overflow
.