public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ray at ultramarine dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/30981] Program "Hangs"
Date: Tue, 27 Feb 2007 18:01:00 -0000	[thread overview]
Message-ID: <20070227180050.23587.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30981-11733@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from ray at ultramarine dot com  2007-02-27 18:00 -------
Subject: Re:  Program "Hangs"


On Tue, 27 Feb 2007, burnus at gcc dot gnu dot org wrote:

> 
> 
> ------- Comment #1 from burnus at gcc dot gnu dot org  2007-02-27 17:07 -------
> Could you post an example?
> 
> pow_r4_i4 means that you have x**a = <real(4)>**<integer(4)>
> 
> I don't see how the exponent "a" can be infinity if it is an integer(4).
> 
      subroutine num_normalize(sigfig,number,   n_normal,exponent)
c
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c
c     ---------------     num_normalize     ---------------
c
c                                             Copyright Ultramarine,inc.
c                                             August 1997
c
c.D
c.D NAME=num_normalize
c.D      Routine to crack NUMBER to characters in ARRAY
c.D OUTPUT
c.D      ARRAY               = Character array of NUMBER
c.D      NPLACE              = Integer*4 Number of Characters used
c.D                            if NPLACE < 0 then could not convert
c.D
c
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c
c
c
c*********************************************      no implicit
c
      implicit none
c
c*********************************************      externals
c
c
c*********************************************      global variables
c
      include '$(where)/amos/include/essential.ecm'
c
c*********************************************      local variables
c
      TYPE_INTEGER exponent,sigfig,pow
      TYPE_REAL number,temp,n_normal,eps
      parameter (eps = 1e-6)
c
c*********************************************      initialize
c
      temp     = abs(number)
      if( temp .lt. r_tiny_n) then
         exponent = 0.
         n_normal = 0.
      else
         exponent = log10(temp)
c hangs after here.
         temp     = temp / (10.**exponent)
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      endif
c
c*********************************************      fix?
c
      if ( n_normal .ge. 10.-eps .and. n_normal .le. 10+eps ) then
         exponent = 0
         n_normal = 10 - eps
      elseif( n_normal .ge. 10. ) then
         exponent = exponent + 1
         temp     = temp * .1
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      elseif( n_normal.lt. 1.) then
         exponent = exponent - 1
         temp     = temp * 10.
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      endif
c
c*********************************************      all done
c
      return
c
      end


> And the following program executes in <4 ms with gfortran 4.3.0 20070227 and
> 4.1.3 20070218 (prerelease) (SUSE Linux).
> 
> You might want to try an newer GCC (4.1.2 or 4.2 or 4.3).
> Nightly builds of the latter two are available from:
> http://gcc.gnu.org/wiki/GFortranBinaries#GNU/Linux

  Thanks, I know about the newer versions, but what I have here is 
  basically working. I just reported this because I hate hangs
  even when I have a bug and generate infinity and then try
  to convert it to a string.

  Thanks again,

  Ray

  PS. Notice the "eps" in the last segment of code. This is 
  really a bug also. It originally was

      If ( n_normal .eq. 10. ) then

  But in some cases it missed the proper branch.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30981


  parent reply	other threads:[~2007-02-27 18:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-27 13:26 [Bug fortran/30981] New: " ray at ultramarine dot com
2007-02-27 17:07 ` [Bug fortran/30981] " burnus at gcc dot gnu dot org
2007-02-27 18:01 ` ray at ultramarine dot com [this message]
2007-02-27 19:35 ` [Bug fortran/30981] a ** exp fails for integer exponents if exp is "-huge()-1" (endless loop) burnus at gcc dot gnu dot org
2007-02-27 19:52 ` ray at ultramarine dot com
2007-02-27 19:54 ` pinskia at gcc dot gnu dot org
2007-02-27 19:58 ` ray at ultramarine dot com
2007-02-27 20:46 ` kargl at gcc dot gnu dot org
2007-02-27 22:04 ` burnus at gcc dot gnu dot org
2007-02-28 22:05 ` tkoenig at gcc dot gnu dot org
2007-02-28 22:39 ` pinskia at gcc dot gnu dot org
2007-02-28 23:13 ` Thomas dot Koenig at online dot de
2007-02-28 23:25 ` kargl at gcc dot gnu dot org
2007-03-01 19:43 ` tkoenig at gcc dot gnu dot org
2007-03-04  8:04 ` tkoenig at gcc dot gnu dot org
2007-03-08 19:27 ` [Bug fortran/30981] [4.2, 4.1 only] " tkoenig at gcc dot gnu dot org
2007-03-08 20:38 ` [Bug fortran/30981] [4.1 " tkoenig at gcc dot gnu dot org

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=20070227180050.23587.qmail@sourceware.org \
    --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: link
Be 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).