4 ms·
Why would you turn on optimization while debugging?
by jimmaswell 8y ago
Why would you turn on optimization while debugging?
- tomjakubowski 8y agoSometimes the bugs don't happen when optimizations are off. (-:
- jolmg 8y agoThat'd be a compiler bug, then. I don't think those would be common. EDIT: I suppose the other possibility is that the program is doing some weird things, like reading its own machine code from memory.
- lmkg 8y agoOr undefined behavior in the program, which happens to manifest differently under different compile options.
- geofft 8y agoNeither of the above are required: your code might be racing with some other API. If your code finishes fast enough, the other code isn't ready for you. With optimizations off, you consistently lose the race and the bug doesn't show up.
- monocasa 8y agoOnce you get used to it, it's not terrible. I don't debug on anything other than release builds (but with symbols) so that I know that I'm debugging the actual issues.
- geofft 8y agoBecause you're debugging a failure in production code. Extraordinarily common.
- pjmlp 8y agoBecause with them turned off, the executable might not fit on the target platform, for example. Quite common on games targeting consoles.
- sys_64738 8y agoScaling your code for benchmarking criteria is a good example.