View Single Post
Old Jun 26th, 2007, 6:59 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Like many problems that involve a program crash, the real cause of your problem is probably pointer molestation (dereferencing a NULL or uninitialised pointer, falling off the end of an array, etc etc). One side effect of adding additional operations (eg output to cout) is changing memory layout of your program -- and, when a pointer is molested, the effected memory can change and therefore the visible effect can change.

Another symptom -- which looks somewhat different but actually has the same root cause -- is a program that crashes until it is recompiled with different compiler optimisation settings, and then it doesn't crash. Again, the reason for the changing symptom is that changing compiler settings change layout of memory used by your application. The cause of the original crash, however, remains.

I would bet that the problem is unlikely to be related specifically to any operations involving cout. iostream functions and objects are pretty commonly used so, if you are using a mature compiler/library, most bugs with will have been ironed out by now.

It's possible that the problem is one of the functions in the MAYA API, but I suggest looking at your own code before blaming third-party code. For example, file parsers often do some form of memory management (eg creating a linked list to represent a parse tree,and later traversing that list) so there are many opportunities for mistakes with pointers.
grumpy is offline   Reply With Quote