mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 17:00:05 +01:00
[SPCA] Finish unorthodox control flow
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static jmp_buf buf;
|
||||
|
||||
void second( void ) {
|
||||
printf( "second\n" );
|
||||
longjmp( buf, 1 );
|
||||
}
|
||||
|
||||
void first( void ) {
|
||||
second();
|
||||
printf( "first\n" ); // Never executed
|
||||
}
|
||||
|
||||
int main() {
|
||||
if ( !setjmp( buf ) ) // returns 0 initially
|
||||
first();
|
||||
else
|
||||
printf( "main\n" ); // 1 is returned when longjmp is executed
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user