Why are compilers so stupid?

前端 未结 29 2004
借酒劲吻你
借酒劲吻你 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:55

    It's an eternal arms race between compiler writers and programmers.

    Non-contrived examples work great -- most compilers do indeed optimize away the obviously useless code.

    Contrived examines will always stump the compiler. Proof, if any was needed, that any programmer is smarter than any program.

    In the future, you'll need more contrived examples than the one's you've posted here.

提交回复
热议问题