Floating point exceptions - gcc bug?
问题 Consider the following code: #include <fenv.h> #include <stdio.h> int main() { #pragma STDC FENV_ACCESS ON 1.0/0.0; printf("%x\n", fetestexcept(FE_ALL_EXCEPT)); } I would expect it to print a nonzero value corresponding to FE_DIVBYZERO , but it prints 0. Changing the second line of main to double x = 1.0/0.0; gives the expected behavior. Is this permitted, or is it a bug? Edit: For what it's worth, at first it may seem that in most real-world code, the operations which might cause fenv