1. 13

  2. 18

    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.

    1. 15

      Dangers of UB, not super smart compilers. I’d personally lay blame on poor language specifications.

      also: http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/

      1. 2

        What will it take to get people to stop using C? This isn’t going to get any better.

        1. 5

          Rust, once it reaches performance parity for doing 3D graphics. Or swift.

          Or nothing, because C/C++ is too ingrained everywhere.

          1. 3

            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

            1. 2

              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.

              1. 2

                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.

            2. 2

              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.

              True story.