This is absolutely legal for a compiler to do, and something that I would expect it to do. gcc loses points in my book by not doing the same. If you want to assign blame, blame the C and C++ language specifications, or the programmer who invoked undefined behavior, or both.
Dangers of UB, not super smart compilers. I’d personally lay blame on poor language specifications.
What will it take to get people to stop using C? This isn’t going to get any better.
Rust, once it reaches performance parity for doing 3D graphics. Or swift.
Or nothing, because C/C++ is too ingrained everywhere.
Rust, once it reaches performance parity for doing 3D graphics
If it’s not already, please file bugs. Check out things like gilium: https://medium.com/@tomaka/the-glium-library-5be149d87dc1#.r2fkx6jkl
Some c software is pretty great, the whole suckless suite of software is pretty simple to read and use, it has its use cases. C++ on the other hand I see being replaced by rust.
I can’t comment on swift, but rust focuses heavily on ownership and ensuring creating and destroying objects and resources goes smoothly.
When I’m writing games/renderers, only a very small (and therefore easy to audit) part of the code actually cares about objects and resources. The rest of the program is written to fill memory and having abstractions on top of that is 1) unhelpful and 2) likely to impact performance.
I’m sure you can write such code in other languages, but then you have all the downsides of a complex and (relatively) immature language, runtime and build system for little or no benefit.
You can make fun of me for not updating to the latest version of every library every time it comes out, but given the time it takes to update libraries on 3 or 4 compilers/build systems and then deal with the chain of dependencies if they don’t all work together, you’ll have to forgive me for choosing to get real work done instead.