function attribute returns_twice
c, c++, function, function-attributes
Solution
The `setjmp` function is analogous to creating a label (in the `goto` sense), as such you will first return from `setjmp` when you set the label, and then each time that you actually jump to it.
If it seems weird, rest assured, you should not be using `setjmp` in your daily programming. Or actually... you should probably not be using it at all. It is a very low-level command that break the expected execution flow (much like `goto`) and, especially in C++, most of the invariants you could expect.
Problem
I just was looking up funciton attributes for gcc (http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html) and came across the `returns_twice` attribute. And I am absolutely clueless in what case a function can return twice... I looked up quickly the mentioned `vfork()` and `setjmp()` but continue without an idea how an applicable scenario looks like - anyone of you used it or can explain a bit?