https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945
--- Comment #3 from Harald Anlauf <anlauf at gmx dot de> --- Self contained alternative testcase: program test implicit none integer, volatile :: id,ierr id = 1 print*,'id=',id call foo1 () print*,'ierr1, OK = ',ierr, ierr == 0 call foo2 () print*,'ierr2, OK = ',ierr, ierr == 0 contains subroutine foo1 () select case(id) case(-HUGE(0):-1) ierr = id case default ierr = 0 end select end subroutine foo1 subroutine foo2 () select case(id) ! case(-HUGE(0)-1:-1) case( :-1) ierr = id case default ierr = 0 end select end subroutine foo2 end program test With -O0: id= 1 ierr1, OK = 0 T ierr2, OK = 0 T With -Og, -O1 and higher: id= 1 ierr1, OK = 0 T ierr2, OK = 1 F