Bug 43115 - bug with gfortran on Windows vista, correct on Linux
Summary: bug with gfortran on Windows vista, correct on Linux
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-18 17:59 UTC by cgerdy
Modified: 2010-04-15 00:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-02-21 04:06:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cgerdy 2010-02-18 17:59:36 UTC
listing of the gfortran program whith the bug
      use iso_fortran_env
      implicit none
      integer,parameter:: mligne = 10000,n2 = 10
      character(len = n2 + 2):: ligne ! the bug is here : 2 is not necessary for reading essai.f95 : 10 max character per line
!     character(len = n2    ):: ligne ! the bug is here did not work : only 8 max character per line
!     character(len = n2 + 1):: ligne ! the bug is here did not work : only 9 max character per line
      character(len = 260):: string
      integer:: i,j,iosta,nligne
      write(output_unit,*) ' name of he file to read'
      read(input_unit,*) string
      open(unit = 7,action = 'read',file = string)
      do i = 1,mligne
         read(unit = 7,fmt = '(a)',iostat = iosta) ligne
         if(iosta .eq. iostat_end) go to 100
         if(iosta .eq. iostat_eor) go to 200
  200    continue
      end do
  100 continue
      close(unit = 7)
      nligne = i - 1
      write(6,*) "number of read lines = ",nligne
      end

listing of the file not correctly read : essai.f95 :
12345
123456
1234567
12345678
123456789
1234567890
123456789
12345678
1234567
123456
12345
Because no bug on Linux : end of line : Carriage return + form feed ?
Comment 1 kargls 2010-02-18 18:15:51 UTC
Please attach the files to the PR.  Cut and paste from
bugzilla will mangle the files; particularly, if it is
a CRLF problem.

Also, try removing your iostat usage and see if the 
the operating system generates an error, or use
iomsg.  Something like

      str = 'OK'
      open(unit = 7, action = 'read', file = string)
      do i = 1,mligne
         read(unit = 7, fmt = '(a)', iostat = iosta, iomsg=str) ligne
         print *, trim(str)

On FreeBSD, I get
troutmask:sgk[223] ./z
  name of he file to read
abc
 OK
 OK
 OK
 OK
 OK
 OK
 OK
 OK
 OK
 OK
 OK
 End of file
 number of read lines =           11


Comment 2 cgerdy 2010-02-18 23:22:43 UTC
Subject: Re:  bug with gfortran on Windows vista, correct on Linux

You have not understand the problem :
It is a gfortran bug, with and only with Windows, you must test this problem 
with Windows not Linux.
The listing of the Fortran file is :
                        Fortran95 file :
      use iso_fortran_env
      implicit none
      integer,parameter:: mligne = 10000,n2 = 10
      character(len = n2 + 2):: ligne ! the bug is here 2 is not necessary 
for reading essai.f95 : 10 max character per line
!     character(len = n2    ):: ligne ! the bug is here, did not work : only 
8 max character per line
!     character(len = n2 + 1):: ligne ! the bug is here, did not work : only 
9 max character per line
      character(len = 260):: string
      integer:: i,j,iosta,nligne
      write(output_unit,*) ' name of he file to read'
      read(input_unit,*) string
      open(unit = 7,action = 'read',file = string)
      do i = 1,mligne
         read(unit = 7,fmt = '(a)',iostat = iosta) ligne
         if(iosta .eq. iostat_end) go to 100
         if(iosta .eq. iostat_eor) go to 200
  200    continue
      end do
  100 continue
      close(unit = 7)
      nligne = i - 1
      write(6,*) "number of read lines = ",nligne
      end
                    end of Fortran95 file

The file to read is, and it is only if you read this file you understand the 
problem, and this file must be a Windows file not a Linux file. Generate it 
with the notepad but in Windows. All the testing work must be made with 
Windows not Linux.
                         file to read : essai.f95
12345
123456
1234567
12345678
123456789
1234567890
123456789
12345678
1234567
123456
12345
                        end of file to read

it is with lines of 10 and 9 characters you have problems with n2 = 10 in 
the Fortan95 program and only with Windows, my Windows is Vista
No problem with gfortran on Linux : my Linux is : Suse11.2

It is the same problem with the use of iomsg=str in the read statement and 
no iostat

The NAG Compiler as the same problem on Windows and not with Linux, exactly 
the same as with gfortran


----- Original Message ----- 
From: "kargl at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <cgerdy@wanadoo.fr>
Sent: Thursday, February 18, 2010 7:15 PM
Subject: [Bug fortran/43115] bug with gfortran on Windows vista, correct on 
Linux


>
>
>
> ------- Comment #1 from kargl at gcc dot gnu dot org  2010-02-18 
> 18:15 -------
> Please attach the files to the PR.  Cut and paste from
> bugzilla will mangle the files; particularly, if it is
> a CRLF problem.
>
> Also, try removing your iostat usage and see if the
> the operating system generates an error, or use
> iomsg.  Something like
>
>      str = 'OK'
>      open(unit = 7, action = 'read', file = string)
>      do i = 1,mligne
>         read(unit = 7, fmt = '(a)', iostat = iosta, iomsg=str) ligne
>         print *, trim(str)
>
> On FreeBSD, I get
> troutmask:sgk[223] ./z
>  name of he file to read
> abc
> OK
> OK
> OK
> OK
> OK
> OK
> OK
> OK
> OK
> OK
> OK
> End of file
> number of read lines =           11
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43115
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> 




Comment 3 kargls 2010-02-19 00:43:08 UTC
(In reply to comment #2)
> Subject: Re:  bug with gfortran on Windows vista, correct on Linux
> 
> You have not understand the problem :
> It is a gfortran bug, with and only with Windows, you must test this problem 
> with Windows not Linux.

I understood the problem.  It is you who does not 
understand.  PLEASE ATTACH THE FILES TO THE BUG
REPORT.  DO NOT PASTE THE FILE INTO YOUR EMAIL
OR BUGZILLA.

When you used iomsg, what did it contain on each 
read?  Did it report that the read was successful?

If you want help, give us the requested information.


Comment 4 Jerry DeLisle 2010-02-19 00:52:09 UTC
I have gfortran freshly compiled on a Vista machine.  I will take a look at this tonight if I can find some time.  This may be a target specific bug, but I can't tell until I observe it first hand. Please attach the files if you can.  Are the lines in the input file as seen with CR-LF right after the last visible character?
Comment 5 Jerry DeLisle 2010-02-19 00:53:46 UTC
The reason the CR-LF is important is that this is basically the only real difference between Linux and Windows other than the OS libraries.
Comment 6 Jerry DeLisle 2010-02-19 05:32:32 UTC
I can not reproduce the problem with gfortran 4.5 on Vista.  What version pf gfortran are you using.  Post the response to "gfortran -v" please.
Comment 7 cgerdy 2010-02-19 09:53:34 UTC
Subject: Re:  bug with gfortran on Windows vista, correct on Linux

Excuse me but I do not understand how correctly use "gfortran -v"
I download gfortran on :
http://gcc.gnu.org/wiki/GFortranBinaries

and on that page : installer(dated 2009-04-21)

After the installation,  it is impossible to read which version of gfortran 
: not in the name of the file : gfortran-windows.exe or in another file in 
the directory gfortran
The only information is : (dated 2009-04-21) on the Internet page.

                Thank you to have been patience.

For me, which is french, to post a bug in the gcc bugzilla is a labyrinth 
work : many question to answer and for, many of them, I do not understand 
them.
My first speciality is : physical mathematic, and my site is :
http://perso.wanadoo.fr/claude.gerdy where students can download in freeware 
an editor for Fortran77, 90, 95, 2003 in fix form or free form.
To navigate in the bugzilla page and answer to the questions it is necessary 
to have a special driving licence...

Thank you very much.

Claude
----- Original Message ----- 
From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <cgerdy@wanadoo.fr>
Sent: Friday, February 19, 2010 6:32 AM
Subject: [Bug fortran/43115] bug with gfortran on Windows vista, correct on 
Linux


>
>
>
> ------- Comment #6 from jvdelisle at gcc dot gnu dot org  2010-02-19 
> 05:32 -------
> I can not reproduce the problem with gfortran 4.5 on Vista.  What version 
> pf
> gfortran are you using.  Post the response to "gfortran -v" please.
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43115
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> 




Comment 8 Jerry DeLisle 2010-02-19 18:56:15 UTC
If the date is correct, it is an older version.

At the command line just type:  gfortran -v

gfortran will then display the version information for you.
Comment 9 cgerdy 2010-02-19 22:17:21 UTC
Subject: Re:  bug with gfortran on Windows vista, correct on Linux

thank you
That is the answer to your question :

C:\Users\gerdy>gfortran -v
Using built-in specs.
Target: i586-pc-mingw32
Configured with: 
../gcc-trunk/configure --prefix=/mingw --enable-languages=c,for
tran --with-gmp=/home/FX/gfortran/dependencies --disable-werror --enable-threads
 --disable-nls --build=i586-pc-mingw32 --enable-libgomp --disable-shared --disab
le-win32-registry --with-dwarf2 --disable-sjlj-exceptions
Thread model: win32
gcc version 4.5.0 20090421 (experimental) [trunk revision 146519] (GCC)



----- Original Message ----- 
From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <cgerdy@wanadoo.fr>
Sent: Friday, February 19, 2010 7:56 PM
Subject: [Bug fortran/43115] bug with gfortran on Windows vista, correct on 
Linux


>
>
>
> ------- Comment #8 from jvdelisle at gcc dot gnu dot org  2010-02-19 
> 18:56 -------
> If the date is correct, it is an older version.
>
> At the command line just type:  gfortran -v
>
> gfortran will then display the version information for you.
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43115
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> 




Comment 10 cgerdy 2010-02-20 16:24:11 UTC
Subject: Re:  bug with gfortran on Windows vista, correct on Linux

I made a new test with an older version of gfortran I had download on your 
Internet page for Windows :
http://gcc.gnu.org/wiki/GFortranBinaries and on that page : installer
It is the only possibility for somebody which is outside of gnu to download 
gfortran for Windows,
and by : gfortran -v, I obtain the version : it was the older 4.2.0 version.
It is necessary to modify my program to test the bug because this older 
version do not know the
line : use iso_fortran_env but and it is important, after that :

This older version of gfortran have not this bug.

So go to the http://gcc.gnu.org/wiki/GFortranBinaries download gfortran and 
test the bug
After that the question for you is : where is the file in this page inside 
gnu and make the correction.

Thank you

Claude
----- Original Message ----- 
From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <cgerdy@wanadoo.fr>
Sent: Friday, February 19, 2010 7:56 PM
Subject: [Bug fortran/43115] bug with gfortran on Windows vista, correct on 
Linux


>
>
>
> ------- Comment #8 from jvdelisle at gcc dot gnu dot org  2010-02-19 
> 18:56 -------
> If the date is correct, it is an older version.
>
> At the command line just type:  gfortran -v
>
> gfortran will then display the version information for you.
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43115
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> 




Comment 11 Jerry DeLisle 2010-02-21 04:06:12 UTC
I have been able to reproduce this with the binary from the wiki.  We get an END condition at line 5 of the test file.  You have to use the test case with:

 character(len = n2    ):: ligne

I have a vague recollection of this bug being fixed since April 2009.....

Most likely PR41328.  The length of the read falls between the CR and the LF.

It is fixed on trunk, so we really need to get that binary on the wiki updated.

Lets hold this PR open until that happens.

 
Comment 12 Jerry DeLisle 2010-04-15 00:48:28 UTC
There are more resent versions of gfortran available at Mingw.  Closing this bug. If the problem persists after updating to more recent, please reopen.