"Walter Bright" <newshou...@digitalmars.com> wrote in message news:hadqcs$30n...@digitalmars.com... > BCS wrote: >> Hello Walter, >> >>> #ponce wrote: >>> >>>> I think it's disabled in debug mode to keep the compilation time low. >>>> >>> That, and the optimizer tends to scramble the relationship between >>> source and assembler, making source debugging next to impossible. >>> >> >> How hard would it be to have the code generate run on the unoptimized >> code and then do the optimizer backed test and only if no bugs jump out, >> move the results into the object file? >> > > It seems even easier to just compile with -0.
It isn't. *Very* typical workflow: 1. Set up a preconfigured single-command "debug" configuration that includes all diagnostics (which involves a lack of -O because it would interfere with debugging) and a preconfigured single-command "release" configuration (which includes -O). 2. Write code, compile "debug" build, test, rinse, repeat until current task/feature is done. 3. Compile "release" build. 4. Goto 2. Marrying diagnostics to -O breaks this workflow no matter how it's handled: Possibility 1: Throw away the system of pre-configured builds and just use the compiler or rebuild directly. Sure, some people do this way normally, but others have very good reasons not to, and it's unreasonable to expect those people switch back to this. Possibility 2: Continue as normal. The errors detected by -O are detected way later than than could be (at best), or are already fixed by the coder (at extra effort) before the compiler has a chance to inform them of it, rendering the feature nearly useless. Possibility 3: Change the debug config to use -O. Say good-bye to useful debuggers. Possibility 4: Split the debug configuration into two separate "debug" modes, one with and one without -O. I can personally vouch from my experience with DMD's "warnings can *only* be treated as errors" that this type of approach is a big mess and PITA. None of those are particularly good options, and I don't see any other possibilities.