Hi, It seems the current gfortran version has a bug when the transfer() function is called on a parameter holding the bitpattern corresponding to the -Infinite value.
If a variable with this pattern is transferred from integer->real->integer the result is just the input. However, when a parameter is transferred in this way, the sign gets reversed, and the bitpattern for -Infinite is changed into the bit pattern for +Infinite. I used the following sample code to test this: PROGRAM TestInfinite IMPLICIT NONE integer, parameter :: i8_ = Selected_Int_Kind(18) ! = integer*8 integer, parameter :: r8_ = Selected_Real_Kind(15,307) ! = real*8 integer(i8_), parameter :: bit_pattern_PosInf_i8_p = 9218868437227405312_i8_ integer(i8_), parameter :: bit_pattern_NegInf_i8_p = -4503599627370496_i8_ integer(i8_) :: bit_pattern_PosInf_i8 = 9218868437227405312_i8_ integer(i8_) :: bit_pattern_NegInf_i8 = -4503599627370496_i8_ integer(i8_) :: bit_pattern_PosInf_i8_hex integer(i8_) :: bit_pattern_NegInf_i8_hex integer(i8_) :: i real(r8_) :: r data bit_pattern_PosInf_i8_hex /z'7FF0000000000000'/ !data bit_pattern_NegInf_i8_hex /z'FFF0000000000000'/ ! not portable, replaced by: bit_pattern_NegInf_i8_hex = ibset(bit_pattern_PosInf_i8_hex,63) print *,"testing the values" print *,"bit_pattern_NegInf_i8_hex = ",bit_pattern_NegInf_i8_hex print *,"bit pattern NegInf_i8 = ",bit_pattern_NegInf_i8 print *,"bit_pattern_PosInf_i8_hex = ",bit_pattern_PosInf_i8_hex print *,"bit pattern PosInf_i8 = ",bit_pattern_PosInf_i8 print *,"testing the variable transfers" print *,"i = ",bit_pattern_PosInf_i8 r = transfer(bit_pattern_PosInf_i8,r) print *,"r = ",r i = transfer(r,i) print *,"i = ",i print *,"i = ",bit_pattern_NegInf_i8 r = transfer(bit_pattern_NegInf_i8,r) print *,"r = ",r i = transfer(r,i) print *,"i = ",i print *,"testing the parameter transfers" print *,"i = ",bit_pattern_PosInf_i8_p r = transfer(bit_pattern_PosInf_i8_p,r) print *,"r = ",r i = transfer(r,i) print *,"i = ",i print *,"i = ",bit_pattern_NegInf_i8_p r = transfer(bit_pattern_NegInf_i8_p,r) print *,"r = ",r i = transfer(r,i) print *,"i = ",i END PROGRAM TestInfinite This program generates the following output on my machine: 12:11pm bhw034 72 >TestInf testing the values bit_pattern_NegInf_i8_hex = -4503599627370496 bit pattern NegInf_i8 = -4503599627370496 bit_pattern_PosInf_i8_hex = 9218868437227405312 bit pattern PosInf_i8 = 9218868437227405312 testing the variable transfers i = 9218868437227405312 r = +Infinity i = 9218868437227405312 i = -4503599627370496 r = -Infinity i = -4503599627370496 testing the parameter transfers i = 9218868437227405312 r = +Infinity i = 9218868437227405312 i = -4503599627370496 r = +Infinity i = 9218868437227405312 12:11pm bhw034 73 > The gfortran version used for testing was: gfortran -v Using built-in specs. Target: i386-pc-linux-gnu Configured with: /home/fxcoudert/gfortran_nightbuild/trunk/configure --prefix=/home/fxcoudert/gfortran_nightbuild/irun-20070525 --enable-languages=c,fortran --build=i386-pc-linux-gnu --enable-checking=release --with-gmp=/home/fxcoudert/gfortran_nightbuild/software Thread model: posix gcc version 4.3.0 20070525 (experimental) best regards, Jos de Kloe -- Summary: bug in transfer integer->real->integer Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kloedej at knmi dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32083