I think that I understand the difference between Release and Debug build modes. The main differences being that in Debug mode, the executable produced isn't optimized (as this could make debugging harder) and the debug symbols are included.
While building PCRE, one of the external dependencies for WinMerge, I noticed a build mode that I hadn't seen before: RelWithDebInfo.
The difference between Debug and RelWithDebInfo is mentioned here: http://www.cmake.org/pipermail/cmake/2001-October/002479.html. exerpt: "RelwithDebInfo is quite similar to Release mode. It produces fully optimized code, but also builds the program database, and inserts debug line information to give a debugger a good chance at guessing where in the code you are at any time."
This sounds like a really good idea, however not necessarily obvious how to set up. This link describes how to enable this for VC++: http://www.cygnus-software.com/papers/release_debugging.html
Am I missing something, or does it not make sense to compile all release code as RelWithDebInfo?
As far as I'm concerned, shipping code to customers without having corresponding debug symbols stored in-house is a recipe for hair-loss when it comes to debugging production problems.
Debugging Release builds with debug symbols is rarely any different from debugging Debug builds, so I'd recommend always doing this.
That said, I don't know if there are any drawbacks. It'd be interesting to hear, if so.
It depends on how much you trust your customer with the debugging information.
Additional Info:
gcc encodes the debugging information into the object code.
Here is the pdb equivalent for gcc:
How to generate gcc debug symbol outside the build target?
Note, that cmake doesn't appear to support this approach out of the box.
Production code doesn't need the size bloat that debugging information carries.
Once you have tried to debug an optimized release build, you know why this is something you only want to do when there is no other way out.
Basically, I see two cases when you'll need this:
I don't know about you, but I had to debug release code twice or thrice in the last decade and managed to work at companies where crashes at customer's were no issue.
Yeah, it's probably a good idea to have debug info for your release builds, too, but VS doesn't set things up this way and for the two cases in each decade where you need this it isn't worth setting this up manually every time. Since CMake gives it for free, do it.
Even when debug info is produced for release build, it is far less useful for debugging purposes than debug build. The reason is that many variables and intermediate expressions are optimized away, and are hence unavailable in the debugger.