For the following code:
integer function KOHb_exit(status)
integer, intent(in) :: status
if (status > 0) call exit(status) ! actually, _FortranAExit
KOHb_exit = 0
do i = 1, status
print '(A,I0)', "KOHb #", i
end do
end function KOHb_exit
one would expect that this code will never have print statement in ASM at high level of optimizations, since execution after exit is not possible. However, current LLVM flang generates print statements at -O3:
https://godbolt.org/z/EzK3nWfrq
For error stop (as well as stop), the code looks cool:
https://godbolt.org/z/7bvhf4Ef3