Hello all,
I remember when I was in some course of C programming, a teacher once suggested to use printf
to watch the execution of a program that I was trying to debug. This program had a segmentation fault with a cause that I cannot remember at the moment. I followed his advice and the segmentation fault disappeared. Fortunately, a clever TA told me to debug instead of using printf
s. In this case, it was an useful thing to do.
So, today I wanted to show someone that using printf
could probably hide a bug. I can find that old code that had this bizarre bug (feature? hmmm).
Question: Have any of you encounter this behavior as well? How could I reproduce something like this?
Thanks a lot!
Edit:
I see that my question part orients my opinion to "using printf
is wrong". I am not exactly saying that and I don't like taking extreme opinions, so I'm editing a bit the question. I agree that printf
is a good tool, but I just wanted to recreate a case where printf
s make a segmentation fault disappear and hence, prove that one must be careful.