emscripten-core / emscripten-core/emscripten

warning: indirection of non-volatile null pointer will be deleted, not trap

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

Description

STR:
```c
#include

int main()
{
printf("Data at address zero: %x\n", *(int*)0);
}
```

```
E:\code\tgifelse>emcc a.c -o a.js
a.c:5:39: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]
printf("Data at address zero: %x\n", *(int*)0);
^~~~~~~~
a.c:5:39: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
1 warning generated.

E:\code\tgifelse>node a.js
Data at address zero: 63736d65
```

This warning looks odd, because the memory load did not get deleted like the warning threatened to do.

The program behaved like I expected it to: load and print the u32 at address zero, which contains the magic bytes for Emscripten stack check.

I wonder if that LLVM warning message should somehow be adjusted for Wasm? Maybe `"warning: indirection of non-volatile null pointer will actually (attempt to) load from memory address zero, and not trap"`?

(We do already have the `-s SAFE_HEAP=1` build mode that will add the necessary checks for this for correctness checks)

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.