Are there risks to optimizing code in C#?

后端 未结 8 827
粉色の甜心
粉色の甜心 2020-12-18 18:53

In the build settings panel of VS2010 Pro, there is a CheckBox with the label \"optimize code\"... of course, I want to check it... but being unusually cautious, I asked my

相关标签:
8条回答
  • 2020-12-18 19:48

    Should optimisations introduce bugs? No.

    Could optimisations introduce bugs? Maybe, nothing's perfect after all.

    Could optimsations uncover bugs that were always in your code, but are hidden when they are turned off? Absolutely, happens quite a bit.

    The important thing is to realise that it's a change. Just like you'd test if you'd done a lot of changes, you should test when you turn them off. If final-release will have them turned on, then final-test must have them turned on too.

    0 讨论(0)
  • 2020-12-18 19:52

    Example wise i have a piece of code from some simulation parts of my master thesis. In which with the optimization flag turned on the code don't really break the program, but the pathfinder only performs one run and loops. (the recursive code traps itself in a loop on the pathfinder which it always breaks out of with the optimization flag turned off).

    So yes it is possible for the optimization flag to make the software behave differently.

    0 讨论(0)
提交回复
热议问题