function
<cfenv>
feraiseexcept
int feraiseexcept (int excepts);
Raise floating-point exception
Attempts to raise the floating-point exceptions specified by excepts.
If more than one exception is specified, the order in which they are raised is unspecified.
Programs calling this function shall ensure that pragma FENV_ACCESS is enabled for the call.
Parameters
- excepts
- Bitmask value: A combination (with bitwise OR) of any number of floating-point exception values supported by the implementation:
 
| macro value | description | 
|---|
 | FE_DIVBYZERO | Pole error: division by zero, or some other asymptotically infinite result (from finite arguments). |  | FE_INEXACT | Inexact: the result is not exact. |  | FE_INVALID | Domain error: At least one of the arguments is a value for which the function is not defined. |  | FE_OVERFLOW | Overflow range error: The result is too large in magnitude to be represented as a value of the return type. |  | FE_UNDERFLOW | Underflow range error: The result is too small in magnitude to be represented as a value of the return type. |  | FE_ALL_EXCEPT | All exceptions (selects all of the exceptions supported by the implementation). |  
 Certain library implementations may support additional floating-point exception values (with their corresponding macros also beginning withFE_).
 
Libraries may define in  <fenv.h> only the macro values above they support (the others may not be defined).
 
At least all of the above macro values are defined in  <cfenv> (even if not supported by the implementation).
 
 
Return Value
Zero, if all exceptions in excepts were successfully raised (or if excepts was zero).
A non-zero value otherwise.
Example
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | /* feraiseexcept example */
#include <stdio.h>      /* printf */
#include <fenv.h>       /* feraiseexcept, fetestexcept, FE_ALL_EXCEPT, FE_INVALID */
#pragma STDC FENV_ACCESS on
double fn (double x) {  /* some function for which zero is a domain error */
  if (x==0.0) feraiseexcept(FE_INVALID);
  return x;
}
int main ()
{
  feclearexcept (FE_ALL_EXCEPT);
  fn (0.0);
  if (fetestexcept(FE_INVALID)) printf ("FE_INVALID raised\n");
  return 0;
}
 | 
Possible output:
Data races
Each thread maintains a separate floating-point environment with its own state. Spawning a new thread copies the current state. [This applies to C11 and C++11 implementations]
Exceptions
No-throw guarantee: this function never throws exceptions.
Note that C floating-point exceptions are not C++ exceptions, and thus are not caught by try/catch blocks.