Panic in Cilk
Running this program will cause it to panic, print an error message, and exit with a non-zero status.
When the first panic
in main
is called, the program exits without reaching the rest of the code. If you’d like to see the program try to create a temp file, comment out the first panic
call.
Note that unlike some languages which use exceptions for handling of many errors, in Cilk (and C in general) it is idiomatic to use error-indicating return values wherever possible. The panic
function in this example is a simple implementation to demonstrate the concept, but it’s not a standard feature of Cilk or C.
In Cilk, error handling is typically done by checking return values of functions. For more complex error handling scenarios, you might use setjmp/longjmp or create your own error handling mechanism.
Remember that Cilk is an extension of C, so many C programming practices apply. The panic
function in this example is used to illustrate a concept similar to Go’s panic, but it’s not a built-in feature of Cilk or C.