tw*******@yahoo.com wrote:
I'm sorry about the vagueness of this post but I don't really know how
to present the problem.
I am writing a numerical integrator and currently the program gets
stuck and I am forced to abort it. When I attempt to add debug code
such as cout << ..., The problem goes away. I can't even pinpoint the
section of code which is causing the problem (this is why I haven't
included any code). I can't understand how the addition of a cout
command could affect the program in this way and I'm going crazy. Does
anyone have any advice?
I've seen it happen and it _can_ be a compiler bug related to the way
the code is generated. It is rather rare. I've had a case where some
variable wouldn't get updated with the result of evaluating of some
expression unless there was a 'cout' thing inserted in the vicinity
of the assignment operator. Awful. I could only find it by making
a release build with debug information (optimisations turned on and
the debug symbols created in a separate file) and actually looking at
the assembly code while stepping through the program. I don't wish
anybody would have to do the same, although sometimes one has to reach
far to get it. I eventually fixed it by declaring that variable as
'volatile'.
What advice to give? Try adding debugging info and run it under the
debugger. Force the debugger to stop (interrupt) your application when
it reached the sticking point. See where it gets stuck. Try to narrow
it down to one function or a block of code. Proceed from that point.
V