[Bug fortran/23138] New: real-values print and add incorrectly (version 4.1.0 20050702, i686-pc-mingw32)

post at tillmann-wegst dot de gcc-bugzilla@gcc.gnu.org
Fri Jul 29 18:54:00 GMT 2005


Hi all, 

I'd like to report what looks like a bug in 
gfortran for Windows, version: 
"GNU F95 version 4.1.0 20050702 (experimental) (i686-pc-mingw32)"

It concerns values of type real, which both print and add 
incorrectly. 

To give an example, take this little program: 

------------------------------------------------
program realtrouble
   real :: x
   integer :: i

   x=1.0
   i=5

   write(*,*) "x==",x    ! Prints 0.0 instead of 1.0 !!! 
   write(*,*) "x==",1.0  ! Prints 0.0 too !!! 
   write(*,*) "i==",i    ! Prints 5, as expected
end program realtrouble
------------------------------------------------------

Apart from incorrect results of write()ing: when summing 
several values of type real, adding 0.0 to 0.0 yielded 2.0, 
adding another 0.0 to 2.0 yielded 0.0 again! 

I've compiled and linked the program at the command-line 
under Windows XP with no particular flags, simply like this: 
    gfortran gftest.f95

Here's what a verbose execution produced: 
Driving: gfortran gftest.f95 -v -lgfortranbegin -lgfortran
Using built-in specs.
Target: i686-pc-mingw32
Configured with: ../gcc/configure --prefix=/mingw --enable-languages=c,f95
Thread model: win32
gcc version 4.1.0 20050702 (experimental)
 c:/gfortran/bin/../libexec/gcc/i686-pc-mingw32/4.1.0/f951.exe gftest.f95 -
quiet -dumpbase gftest.f9
5 -mtune=pentiumpro -auxbase gftest -version -o C:\DOKUME~1\Tillmann\LOKALE~1
\Temp/ccWqbaaa.s
GNU F95 version 4.1.0 20050702 (experimental) (i686-pc-mingw32)
        compiled by GNU C version 3.4.4 (mingw special).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -o C:\DOKUME~1\Tillmann\LOKALE~1\Temp/ccIHcaaa.o C:\DOKUME~1
\Tillmann\LOKALE~1\Temp/ccWqbaaa.s
 c:/gfortran/bin/../libexec/gcc/i686-pc-mingw32/4.1.0/collect2.exe -Bdynamic 
C:/fortran/g95/lib/crt2
.o -Lc:/gfortran/bin/../lib/gcc/i686-pc-mingw32/4.1.0 -
Lc:/gfortran/bin/../lib/gcc -LC:/fortran/g95/
lib -Lc:/gfortran/bin/../lib/gcc/i686-pc-mingw32/4.1.0/../../.. C:\DOKUME~1
\Tillmann\LOKALE~1\Temp/c
cIHcaaa.o -lgfortranbegin -lgfortran -lmingw32 -lgcc -lmoldname -lmingwex -
lmsvcrt -luser32 -lkernel
32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
--------------------------------------

I've exchanged mails with Steven Kargl, who suggested to 
produce a .original-file using flag "-fdump-tree-original". 

This generated the following: 
MAIN__ ()
{
  real4 x;
  int4 i;

  x = 1.0e+0;
  i = 5;
  _gfortran_filename = "gftest.f95";
  _gfortran_line = 8;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  _gfortran_transfer_character ("x==", 3);
  _gfortran_transfer_real (&x, 4);
  _gfortran_st_write_done ();
  _gfortran_filename = "gftest.f95";
  _gfortran_line = 9;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  _gfortran_transfer_character ("x==", 3);
  {
    real4 C.473 = 1.0e+0;

    _gfortran_transfer_real (&C.473, 4);
  }
  _gfortran_st_write_done ();
  _gfortran_filename = "gftest.f95";
  _gfortran_line = 10;
  _gfortran_ioparm.unit = 6;
  _gfortran_ioparm.list_format = 1;
  _gfortran_st_write ();
  _gfortran_transfer_character ("i==", 3);
  _gfortran_transfer_integer (&i, 4);
  _gfortran_st_write_done ();
}
------------------------------------ 

Steve's preliminary conclusion is (quote):
"(...).original shows that the gfortran frontend is
doing the right thing.  This is a gfortran library problem
or an interface with OS library problem." 

Kind regards 
   Tillmann Wegst

-- 
           Summary: real-values print and add incorrectly (version 4.1.0
                    20050702, i686-pc-mingw32)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: post at tillmann-wegst dot de
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list