Even in C99 there is no portable way to do this. This works on Linux:
#define _GNU_SOURCE #include <fenv.h> int main(void) { fesetenv(FE_NOMASK_ENV); feraiseexcept(FE_UNDERFLOW); return 0; }
but without calls to #define _GNU_SOURCE and fesetenv (which are not fesetenv ), an exception is not thrown (== does not start SIGFPE , in Unix terms), it just sets a flag. And no MSVC iteration supports <fenv.h> , so you are stuck with completely non-standard on Windows.
However, it seems to be the equivalent of Windows:
#include <float.h> #pragma fenv_access (on) int main(void) { _controlfp_s(0, 0, _MCW_EM); /* throw all floating point exceptions */ /* trigger floating-point underflow here */ }
You will need to invoke the underflow condition using floating point operations. I do not know how to do it from my head. It would be best to do this manually in assembly language, to avoid interference from the compiler (not even portability anymore, yes, but if you're on Windows, you probably don't need any processor, but x86).
source share