In MPFR's documentation (both HTML and PDF) I cannot find the semantics of return values of assignment functions. For example, what is the meaning of return value of mpfr_set
?
Extra: quite surprised that MPFR's initialization functions return void
. So, if initialization fails, then the program will gmp_die()
leading to abort()
. What if in case of MPFR's initialization failure one needs the program running?
Like for most functions, the return value of the assignment functions is the ternary value.
Note that initialization will never fail, except in case of out of memory; but in this case, the abort instead of an error is due to a limitation of GMP, on which MPFR is based. To keep the program running, catching SIGABRT
might be a solution (or use your own memory allocation functions via GMP's custom allocation), but the data structures of GMP and MPFR are in an indeterminate state, so that it may be very difficult to recover, if not impossible: as the GMP manual says in Custom Allocation:
There's currently no defined way for the allocation functions to recover from an error such as out of memory, they must terminate program execution. A longjmp or throwing a C++ exception will have undefined results. This may change in the future.
Basically, you would need a separate process and a way to transfer the data (possibly shared memory).