https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112338
Bug ID: 112338 Summary: ieee_set_halting_mode only affects the master thread outside of an OpenMP parallel region Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: vladimir.fuka at gmail dot com Target Milestone: --- Calling ieee_set_halting_mode only affects the master thread if other threads already exist and the call is done outside of a parallel region. I am not sure what the Fortran standard and the OpenMP specifications prescribe, but the following code produces different results with GCC and with Intel. use ieee_exceptions implicit none integer, parameter :: n = 100 real :: nom(n) integer :: denom(n) logical :: saved_fpe_mode(size(ieee_all)) integer :: i nom = 1 denom = 0 call ieee_set_halting_mode(ieee_overflow, .true.) call ieee_set_halting_mode(ieee_invalid, .true.) call ieee_set_halting_mode(ieee_divide_by_zero, .true.) !$omp parallel print *,"hello from a thread" !$omp end parallel call ieee_get_halting_mode(ieee_all, saved_fpe_mode) call ieee_set_halting_mode(ieee_all, .false.) !$omp parallel do do i = 1, n nom(i) = nom(i) / denom(i) end do !$omp end parallel do nom = min(max(0., nom), 1.) !$omp parallel call ieee_set_halting_mode(ieee_all, saved_fpe_mode) !$omp end parallel print *, nom end With GCC gfortran-13 -fopenmp -g fpe.f90 the code halts on line 28 (nom(i) = nom(i) / denom(i)) with SIGFPE: Floating-point exception - erroneous arithmetic operation. With Intel ifx -qopenmp -g fpe.f90 the code does not halt and prints all 1.000000s.