Martin Franke wrote: > The crash occurs in > the initialisation routine of a certain module. Now, when inserting a > printf("bla") right at start-up in main() the crash goes away, removing > it makes it re-appear, so it is perfectly reproducible. The printf is in > a different object file than where the crash happens and quite a lot of > code is executed between the printf and the crash. > > So my questions are: > - Is this a side-effect to be expected?
Yes, in that it can change the behaviour, no in that printf() is not a cure to make crashes go away. ;) > - How can the additional printf in one object file can have a > side-effect on the code in another object file? Every function call modifies the stack and possibly some registers (I'm not 100% sure when and how the latter are modified). The former means that if you then create an uninitialised variable on the stack its value might be modified. The latter means that code to save and restore register content is created. Both together or each for itself could cause the program's behaviour to change, in particular if there is some undefined behaviour already going on. Uli -- http://gcc.gnu.org/faq.html http://parashift.com/c++-faq-lite/ _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus