Hang on, I misread you, my eye skipped over the bit where you suggest that
adding the check somehow makes the preceding fopen call succeed instead of
fail. However I still don't think that's what the OP was saying, unless the
subject line of this thread is terribly wrong, I think you just read a bit too
much into OP's phrase "everything worked"; I think that just means "program
ran to completion /without/ a segfault".
It was more than that:
>and then rebuilding the code, everything worked. But it's strange that
>if I delete that code segment and never check whether the fp pointer is
>NULL or not, I always get a segmentation fault. Can this be some kind
>of an optimization problem? I don't know why it happens. Thank you for
>the comments.
Especially when he suggested it was a problem with the compiler
optimizer, I am pretty sure that he means the code is working as
expected with this check in there, and he doesn't understand why. (The
subject line applies from back before he tried this.)
But anyway you could be right too, I guess there's no point in guessing
what he meant...
-Lewis
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/