Why are compilers so stupid?

前端 未结 29 1957
借酒劲吻你
借酒劲吻你 2020-11-29 18:07

I always wonder why compilers can\'t figure out simple things that are obvious to the human eye. They do lots of simple optimizations, but never something even a little bit

29条回答
  •  眼角桃花
    2020-11-29 18:57

    I think you are underestimating how much work it is to make sure that one piece of code doesn't affect another piece of code. With just a small change to your examples x, i, and s could all point to the same memory. Once one of the variables is a pointer, it is much harder to tell what code might have side effects depending on is point to what.

    Also, I think people who program compliers would rather spend time making optimizations that aren't as easy for humans to do.

提交回复
热议问题