Description
a.cpp
#include <emscripten/emscripten.h>
#include <stdint.h>
int main()
{
int index = EM_ASM_INT(return 0);
uint32_t val = EM_ASM_INT(return 0xDFFFFFFE);
uint32_t val2 = EM_ASM_INT(return 0xDFFFFFFE);
EM_ASM(console.log($0), val == val2 >> index);
}
compiled with em++ a.cpp -o a.js -O1 -s WASM=0
incorrectly prints out 0
, whereas it should print 1
.
Generated main
is
function main($0, $1) {
$0 = $0 | 0;
$1 = $1 | 0;
$0 = global$0 - 16 | 0;
global$0 = $0;
$1 = emscripten_asm_const_iii(1024, 1033, 0) | 0;
HEAP32[$0 >> 2] = (emscripten_asm_const_iii(1034, 1033, 0) | 0) == emscripten_asm_const_iii(1034, 1033, 0) >>> $1;
emscripten_asm_const_iii(1052, 1068, $0 | 0) | 0;
global$0 = $0 + 16 | 0;
return 0;
}
where (emscripten_asm_const_iii(1034, 1033, 0) | 0)
yields -536870914
, whereas the right side emscripten_asm_const_iii(1034, 1033, 0) >>> $1
is unsigned and evaluates to 3758096382
.
Metadata
Metadata
Assignees
Labels
No labels