# wasi-libc: compile emmalloc.c without strict aliasing \(\#16157\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e7f872c9c6063e3d4e4f9bf46e998204b72fa84a)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e7f872c9c6063e3d4e4f9bf46e998204b72fa84a

Requested commit: e7f872c9c6063e3d4e4f9bf46e998204b72fa84a

Commit: e7f872c9c6063e3d4e4f9bf46e998204b72fa84a

Tree: b8859c4b3ab5fa6b455ddbae6559fa12efd173cb

Author: Frank Denis

Committer: GitHub

## Message

```
wasi-libc: compile emmalloc.c without strict aliasing (#16157)

emmalloc.c does a fair amount of type punning in order to access
the size of memory regions and traverse them.

Unfortunately, that can lead to unwanted optimizations.

This simple test case currently triggers a memory fault:

int main(void) {
    char * volatile p = malloc(1);
    p = realloc(p, 12);
    p = malloc(1);
    printf("%p\n", p);
}

Work around this by adding "-fno-strict-aliasing" when compiling
that file.
```

## Parents

- [b11170294052585ae81b9946d770f860d163da8f](https://git.cafe/gitcafe/zig/commit/b11170294052585ae81b9946d770f860d163da8f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e7f872c9c6063e3d4e4f9bf46e998204b72fa84a?format=markdown)
