Just to give some context, I’m talking about compiling C++ code with g++ here.
I can see how including the -g flag for production builds would be convenient for maintenance: the program will be much easier to debug if it crashes unexpectedly.
My question here is, does including the -g flag affect the output executable in any other way than increasing its size? Can it somehow make the code slower (e.g. by turning off certain optimizations)?
From what I understand, it shouldn’t (the documentation only mentions the inclusion of debug symbols), but I’m not sure.
The -g flag does not affect code generation, only the symbol table and debug metadata are changed. Those do not live in the executable code section, so they won’t even affect performance when the code is run outside of hte debugger.