OK for whatever reason I\'m having trouble causing a seg fault. I want to produce one so that I can use gdb
to see how to debug one. I have tried both examples
The Wikipedia article actually lists three methods (one of which is a null pointer dereference); why didn't you try that one?
As for why the two examples you tried didn't, well, the correct answer as others have noted is that it's undefined behavior, so anything could happen (which includes not segfaulting). But one could speculate that the reason that the first form didn't fail for you is because your compiler or system is lax about memory protection. As for the second case, a tail-recursive-aware compiler conceivably could optimize the infinitely recursive main
loop and not end up overflowing the stack.