You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser.
printf version, which has more readable assembly: https://godbolt.org/z/5r41516Px
The answer's going to be because there's undefined behaviour...
3
When invoking undefined behavior, anything the compiler outputs is legal, so in particular, a compiler can optimize under the assumption that UB...
These posts explain the issue very well (and they apply to both Rust/C++/any language with similar memory models):
- Pointers Are Complicated, or...