emscripten-core / emscripten-core/emscripten
c++ alignas(8) makes memory access out of bounds
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I'm using emcc to build my c++ code in web application. There is an error 'memory access out of bounds' in dlmalloc and dlfree after I new and free some c++ objects several times. After debugging for weeks, I find a member variable causes this error.
Sample code:
`
class MessageBuilder {
private:
alignas(8) void* arenaSpace[22]; // variable causes error.
};
`
After I change it to:
`
class MessageBuilder {
private:
void* arenaSpace[22]; // variable causes error.
};
`
the error disappears.
Still, I don't understand why alignas(8) makes difference. Is it correct that I remove alignas(8)? Could someone please explain it?
Contributor guide
Assessment
This issue has not been assessed yet.