https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109186
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2023-03-19 Keywords| |wrong-code --- Comment #3 from anlauf at gcc dot gnu.org --- Confirmed. This is a compile-time issue. When the first argument of NEAREST is a variable and not a constant expression, I get the correct result: program p real, parameter :: x = huge(1.0) real :: y, z y = x z = nearest (y, -1.0) print *, nearest (x, -1.0), z end This prints: 1.70141173E+38 3.40282326E+38 Seems to affect all versions at least down to 7.