emscripten-core / emscripten-core/emscripten
wrong code at -Os and -O2
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
```
[505] % emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.42 (6ede0b8fc1c979bb206148804bfb48b472ccc3da)
clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /local/home/suz/suz-local/software/emsdk/upstream/bin
[506] %
[506] % emcc -O1 -w small.c; node ./a.out.js
[507] % emcc -Os -w small.c
[508] % node ./a.out.js
...
RuntimeError: divide by zero
at wasm://wasm/78d4aa8e:wasm-function[1]:0x13b
...
[509] %
[509] % cat small.c
long a, c = 1, f, j = 6;
int b, e, i, k, n, o, p;
short d;
unsigned g;
char h, m;
static short z() {
long q = 10;
int r = -2, s = ~(~b & (i && 1 / j));
if (s <= -2) {
if (i < 0)
goto t;
goto u;
}
b = d = 1;
v:
while (b < 1)
;
for (; o < 7; o++) {
if (!(9 < q))
goto t;
q = 0;
if (n)
break;
if (k)
goto v;
short w = 0;
long long x = 0;
unsigned y;
long l = d || r | b;
if (h > 1)
u:
p;
if (l >= -1) {
w = d;
x = y = r;
if (e)
continue;
r = a;
t:
if (y < x)
g = -1 / (d % w);
if (!c)
goto u;
if (!j)
goto t;
}
f = 0;
}
return m;
}
int main() { z(); }
```
Contributor guide
Assessment
This issue has not been assessed yet.