public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kloedej at knmi dot nl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/32083] New: bug in transfer integer->real->integer Date: Fri, 25 May 2007 10:17:00 -0000 [thread overview] Message-ID: <bug-32083-11277@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2007-05-25 10:17 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-05-25 10:17 kloedej at knmi dot nl [this message] 2007-05-25 10:45 ` [Bug fortran/32083] " dfranke at gcc dot gnu dot org 2007-05-25 11:37 ` [Bug fortran/32083] [Regression 4.3] " burnus at gcc dot gnu dot org 2007-05-26 21:11 ` burnus at gcc dot gnu dot org 2007-05-26 22:00 ` patchapp at dberlin dot org 2007-05-27 8:10 ` [Bug middle-end/32083] [4.3 Regression] " burnus at gcc dot gnu dot org 2007-05-27 8:18 ` burnus at gcc dot gnu dot org 2007-05-27 13:57 ` burnus at gcc dot gnu dot org 2007-05-29 7:30 ` kloedej at knmi dot nl
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-32083-11277@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).