cout, the root of all evil

Started by
11 comments, last by GameDev.net 19 years, 7 months ago
After days of thoroughly testing a project I'm ready to compile it in its final incarnation, so I remove all my debugging cout's. Segmentation Fault. Great. I put them back in, and I narrow it down to one cout that when it's there, whatever it prints (I've tried many, example "WHY, GOD, WHY?"), the segmentation fault occurs. I've never encountered this before, so I'm sort of clueless as to what this is a symptom of. Obviously I've messed up my memory somewhere, but why then would the program run fine with this stupid cout in it and not without? Anyone have any tips?
Advertisement
Are you couting the result of a function? Is that function important?
Not giving is not stealing.
I highly doubt that fault is with cout. [smile]
check out the Memory Manager on:

http://www.fluidstudios.com/
Chris-
Yeah, I'm not saying it is, but the fact remains that my program executes flawlessly with the cout that isn't tied to any function (i.e. not getting its intput from any function), but it segfaults without it.

lonesock-
Trying that out now...
Did you change from debug to release at any time? That often causes unforseen problems to arise...
Heh, I've had similar things occur with printf [in plain jane C, but the same applies...]. Essentially the cout isn't breaking your code, it's causing whatever buffer overflow you're causing [edit: in some probably wholy unrelated area] to overwrite something innocent [like the cout string] rather than something vital. The program will happily print garbage if the cout debugging message gets overwritten. Overwrite a pointer's value or something though, and things go downhill quickly.

[edit: the only real way to find the damn problem is generally to narrow it down to a cout that your program won't run without, then step through the code evaluating the cout. Once the output changes, that's where the bug is.

Needless to say, it's a pita.]
Man why dont I get interesting bugs like that?! :P
Emil Johansen- SMMOG AI designerhttp://smmog.com
Quote:Original post by emileej
Man why dont I get interesting bugs like that?! :P


In the interest of maintaining the flame-free environment of this thread, I will suppress the obvious retort
daerid@gmail.com
I had a similar problem once; it turned out I'd forgotten to return a value from a function.

This topic is closed to new replies.

Advertisement