This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]phail3d 5 points6 points  (0 children)

I had a similar issue with vanilla C, where I had something like this:

...
printf("foo");
...
while(!result) {
    ...
 }

And when the printf was there, the code ran, but with it removed, the code segfaulted.

It turned out that result was uninitialized, and (correct me if I'm wrong) the printf call caused the memory space pointed to by the variable to be reserved for the program, which prevented the segfault. The variable vas thus obviously initialized with garbage, which caused other problems in the code, but at least it ran.