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?
The
setjmpfunction is analogous to creating a label (in thegotosense), as such you will first return fromsetjmpwhen 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
setjmpin 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 likegoto) and, especially in C++, most of the invariants you could expect.