public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c
@ 2004-08-25 23:48 sgk at troutmask dot apl dot washington dot edu
  2004-08-25 23:49 ` [Bug libfortran/17195] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2004-08-25 23:48 UTC (permalink / raw)
  To: gcc-bugs

This program,

   program t
   real(8) y
   print*, 'huge(y) = ', huge(y)
   end program t

when compiled with "gfortran -static -o t t.f90" leads
to a program "t", which executes an infinite loop.  The 
problem is in libgfortran/io/write.c where write_real()
sets the global variable g.scaling=1.  We eventually end
up executing this code in output_float() where
n = huge(y) and sca = 1.

  if (ft == FMT_F || ft == FMT_E || ft == FMT_D)
    {
      if (ft == FMT_F)
        scale_flag = 0;
      if (ft == FMT_D)
        exp_char = 'D' ;
      minv = 0.1;
      maxv = 1.0;

      /* Calculate the new val of the number with consideration
         of global scale value.  */
      while (sca >  0)
        {
          minv *= 10.0;
          maxv *= 10.0;
          n *= 10.0;       /* XXXXX huge(y) * 10 becomes Inf. */
          sca -- ;
          neval --;
        }

      /* Now calculate the new Exp value for this number.  */
      sca = g.scale_factor;
      while(sca >= 1)
        {
          sca /= 10;
          digits ++ ;
        }
    }

Further down, we hit this loop and n = Inf > maxv, forever.

   while (scale_flag && n > 0.0 && n > maxv)
     {
       if (n > maxv)
         {
           n = n / 10.0 ;
           neval ++;
         }
     }

-- 
           Summary: Infinite loop in output_float in libgfortran/io/write.c
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sgk at troutmask dot apl dot washington dot edu
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: amd64-unknown-freebsd5.2


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/17195] Infinite loop in output_float in libgfortran/io/write.c
  2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
@ 2004-08-25 23:49 ` pinskia at gcc dot gnu dot org
  2004-08-26 20:32 ` sgk at troutmask dot apl dot washington dot edu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-25 23:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-25 23:49 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-25 23:49:52
               date|                            |


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/17195] Infinite loop in output_float in libgfortran/io/write.c
  2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
  2004-08-25 23:49 ` [Bug libfortran/17195] " pinskia at gcc dot gnu dot org
@ 2004-08-26 20:32 ` sgk at troutmask dot apl dot washington dot edu
  2004-08-28 19:48 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2004-08-26 20:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2004-08-26 20:32 -------
For a patch see http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02180.html

-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/17195] Infinite loop in output_float in libgfortran/io/write.c
  2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
  2004-08-25 23:49 ` [Bug libfortran/17195] " pinskia at gcc dot gnu dot org
  2004-08-26 20:32 ` sgk at troutmask dot apl dot washington dot edu
@ 2004-08-28 19:48 ` cvs-commit at gcc dot gnu dot org
  2004-08-28 22:03 ` pinskia at gcc dot gnu dot org
  2004-08-31 20:58 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-28 19:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-28 19:48 -------
Subject: Bug 17195

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2004-08-28 19:48:03

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog libgfortran.h 
	libgfortran/io : write.c 
	libgfortran/runtime: error.c 
Added files:
	gcc/testsuite/gfortran.dg: edit_real_1.f90 

Log message:
	PR libfortran/17195
	* libgfortran.h (rtoa): Remove prototype.
	* runtime/error.c (rtoa): Remove.
	* io/write.c (calculate_G_format): Don't add blanks if E format is
	used.  Add correct number of blanks when exponent width is specified.
	(output_float): Rewrite.
	testsuite/
	* gfortran.dg/edit_real_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4203&r2=1.4204
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/edit_real_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.69&r2=1.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/libgfortran.h.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&r1=1.11&r2=1.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/runtime/error.c.diff?cvsroot=gcc&r1=1.3&r2=1.4



-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/17195] Infinite loop in output_float in libgfortran/io/write.c
  2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
                   ` (2 preceding siblings ...)
  2004-08-28 19:48 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-28 22:03 ` pinskia at gcc dot gnu dot org
  2004-08-31 20:58 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-28 22:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-28 22:03 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/17195] Infinite loop in output_float in libgfortran/io/write.c
  2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
                   ` (3 preceding siblings ...)
  2004-08-28 22:03 ` pinskia at gcc dot gnu dot org
@ 2004-08-31 20:58 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-31 20:58 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.5.0


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-31 20:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-25 23:48 [Bug libfortran/17195] New: Infinite loop in output_float in libgfortran/io/write.c sgk at troutmask dot apl dot washington dot edu
2004-08-25 23:49 ` [Bug libfortran/17195] " pinskia at gcc dot gnu dot org
2004-08-26 20:32 ` sgk at troutmask dot apl dot washington dot edu
2004-08-28 19:48 ` cvs-commit at gcc dot gnu dot org
2004-08-28 22:03 ` pinskia at gcc dot gnu dot org
2004-08-31 20:58 ` pinskia at gcc dot gnu dot org

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).