emscripten-core / emscripten-core/emscripten

[acorn-optimizer] unsignPointers can cause problems optional second argument `subarray`

Open
#21,250 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

The `unsignPointers` pass will currently add `>>> 0` to all arguments to `\.subarray`.

However, if the value being passed is `undefined` this changes its meaning.

The case I found was in `library_glemu.js` which does something like this: `HEAP16.subarray(ptr, end ? end : undefined)`.

In the case when `end` is undefined this ends up being `end >>> 0` which is 0, and which is very different to `undefined` when passed as this argument.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.