2 ms·
Sadly I don't think that's true. A first year CS undergraduate would not be writing code that triggered a compiler bug, the real problem was most likely your co
by grkvlt 10y ago
Sadly I don't think that's true. A first year CS undergraduate would not be writing code that triggered a compiler bug, the real problem was most likely your code.
I suspect you had an error in your program, an off-by-one or other type of overflow, that caused the stack to be executed. Compiling without debug would mean that the code executed was harmless, compiling with debugging symbols (the -g option in gcc) enabled caused a different memory layout, which triggered an attempt to execute data that contained an illegal instruction. Since in debug mode comments are included in the data segment, adding a space to a comment further changed the memory layout making the error innocuous again.
// EDIT After thinking about this a bit more, I'm not entirely convinced by my explanation since comments aren't included in the debug symbols. However, I still think it's more likely that a debug (versus optimized) build had different memory layout, and therefore different behaviour in the presence of a stack/heap smashing bug...?