nncarlson / gfortran.dg

The GFortran testsuite rigged for testing other Fortran compilers
7 stars 2 forks source link

invalid code in ieee_8.f90 #21

Open ThemosTsikas opened 6 years ago

ThemosTsikas commented 6 years ago

The ieee_8.f90 test

program test
  use :: bar
  use :: ieee_arithmetic, xxx => ieee_support_rounding
  implicit none

  ! IEEE functions allowed in constant expressions

  integer, parameter :: n1 = ieee_selected_real_kind(0, 0)
  logical, parameter :: l1 = ieee_support_halting(ieee_overflow)
  logical, parameter :: l2 = ieee_support_flag(ieee_overflow)
  logical, parameter :: l3 = ieee_support_flag(ieee_overflow, 0.)
  logical, parameter :: l4 = ieee_support_rounding(ieee_to_zero)
  logical, parameter :: l5 = ieee_support_rounding(ieee_to_zero, 0.d0)

  logical, parameter :: l6 = xxx(ieee_to_zero, 0.d0)
  logical, parameter :: l7 = yyy(ieee_to_zero, 0.d0)
  integer, parameter :: n2 = zzz(0, 0)

  call gee(8, ieee_to_zero, ieee_overflow)

end

ignores the Technical Corrigendum 4 (http://isotc.iso.org/livelink/livelink?func=ll&objId=18597225&objAction=Open) items which correct the standard to make IEEE_SUPPORT_FLAG, IEEE_SUPPORT_HALTING and IEEE_SUPPORT_ROUNDING Transformational functions instead of Inquiry. According to the rules for constant expressions, these functions cannot be used in constant expressions.

janusw commented 6 years ago

Indeed. Seems like ifort 18 catches this:

$ ifort ieee/ieee_8.f90 
ieee/ieee_8.f90(23): error #6259: This array or function or substring is invalid in constant expressions.   [IEEE_SUPPORT_HALTING]
  logical, parameter :: l1 = ieee_support_halting(ieee_overflow)
-----------------------------^
ieee/ieee_8.f90(24): error #6259: This array or function or substring is invalid in constant expressions.   [IEEE_SUPPORT_FLAG]
  logical, parameter :: l2 = ieee_support_flag(ieee_overflow)
-----------------------------^
ieee/ieee_8.f90(25): error #6259: This array or function or substring is invalid in constant expressions.   [IEEE_SUPPORT_FLAG]
  logical, parameter :: l3 = ieee_support_flag(ieee_overflow, 0.)
-----------------------------^
ieee/ieee_8.f90(26): error #6259: This array or function or substring is invalid in constant expressions.   [IEEE_SUPPORT_ROUNDING]
  logical, parameter :: l4 = ieee_support_rounding(ieee_to_zero)
-----------------------------^
ieee/ieee_8.f90(27): error #6259: This array or function or substring is invalid in constant expressions.   [IEEE_SUPPORT_ROUNDING]
  logical, parameter :: l5 = ieee_support_rounding(ieee_to_zero, 0.d0)
-----------------------------^
ieee/ieee_8.f90(29): error #6259: This array or function or substring is invalid in constant expressions.   [XXX]
  logical, parameter :: l6 = xxx(ieee_to_zero, 0.d0)
nncarlson commented 6 years ago

This was nag-20180203d.f90 in https://github.com/nncarlson/fortran-compiler-tests. I've deleted it.