public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43155]  New: Reading real numbers of the form "123+ 44" (with space)
@ 2010-02-23 20:58 burnus at gcc dot gnu dot org
  2010-02-23 21:28 ` [Bug fortran/43155] " kargl at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-23 20:58 UTC (permalink / raw)
  To: gcc-bugs

The following program runs with ifort, sunf95, and pathscale, but it fails with
gfortran, NAG f95 and g95. I think the number is not standard conform, but a
"processor" is allowed to accept it. For "a" ifort et al. print "4380000.0".


Additionally, I have the feeling that there is an off-by-one error in the error
message; at least I expect "2" rather than "3" in the message.


At line 4 of file test.f90
Fortran runtime error: Expected REAL for item 3 in formatted transfer, got
INTEGER



character(len=200) :: str
real :: x
str = ' 4.38000+ 6 2.55100+ 0 4.50000+ 6 2.51970+ 0 5.00000+ 6 2.40000+ 01146 3
1 171'
read(str,'(6e11.0,i4,i2,i3,i5)') a,math,mfh,mth,nsp
print *, a
end


-- 
           Summary: Reading real numbers of the form "123+ 44" (with space)
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/43155] Reading real numbers of the form "123+ 44" (with space)
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
@ 2010-02-23 21:28 ` kargl at gcc dot gnu dot org
  2010-02-24  2:55 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-02-23 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2010-02-23 21:28 -------
Interesting bug.

I think one needs to read 9.4.5.4 that defines
the interpretation of blanks as BLANK=NULL, and
10.7.6 which I think means your string should
be seen as (note there are 2 space before
each REAL).

'  4.38000+6  2.55100+0  4.50000+6  2.51970+0  5.00000+6  2.40000+01146 3 1 71'


-- 


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


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

* [Bug fortran/43155] Reading real numbers of the form "123+ 44" (with space)
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
  2010-02-23 21:28 ` [Bug fortran/43155] " kargl at gcc dot gnu dot org
@ 2010-02-24  2:55 ` jvdelisle at gcc dot gnu dot org
  2010-02-24  4:01 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-02-24  2:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2010-02-24 02:55 -------
Do you intend math, mfh, mth, and nsp to be of type integer or real?

The following works:

character(len=200) :: str
real :: x,math,mfh,mth,nsp
str = ' 4.38000+ 6 2.55100+ 0 4.50000+ 6 2.51970+ 0 5.00000+ 6 2.40000+ 01146 3
1 171'
read(str,'(6e11.0,i4,i2,i3,i5)') a,math,mfh,mth,nsp
print *, a,math,mfh,mth,nsp
end

(As I first read the bug report I though the issue is with BN/BZ handling. 
That part is correct, the problem is in the item count.)

I agree with the off by one in the item count, it is item 2.  I will fix that.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-02-24 02:55:18
               date|                            |


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


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

* [Bug fortran/43155] Reading real numbers of the form "123+ 44" (with space)
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
  2010-02-23 21:28 ` [Bug fortran/43155] " kargl at gcc dot gnu dot org
  2010-02-24  2:55 ` jvdelisle at gcc dot gnu dot org
@ 2010-02-24  4:01 ` jvdelisle at gcc dot gnu dot org
  2010-02-24  7:06 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-02-24  4:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2010-02-24 04:01 -------
Here is the fix:

Index: transfer.c
===================================================================
--- transfer.c  (revision 156986)
+++ transfer.c  (working copy)
@@ -926,7 +926,7 @@ require_type (st_parameter_dt *dtp, bt expected, b
     return 0;

   sprintf (buffer, "Expected %s for item %d in formatted transfer, got %s",
-          type_name (expected), dtp->u.p.item_count, type_name (actual));
+          type_name (expected), dtp->u.p.item_count - 1, type_name (actual));

   format_error (dtp, f, buffer);
   return 1;

The reason this is the right fix is that for formatted transfers, the loop that
calls the transfers is executed an initial time to set up the transfer and then
looped throughthe items.  Item count is always one greater.  We could
initialize it to -1, but why bother, the dtp structure is zeroed when created. 
The above is the minimal fix.  I will add a comment to explain this when I
commit.  Regression tests OK.


-- 


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


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

* [Bug fortran/43155] Reading real numbers of the form "123+ 44" (with space)
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-02-24  4:01 ` jvdelisle at gcc dot gnu dot org
@ 2010-02-24  7:06 ` burnus at gcc dot gnu dot org
  2010-02-25  5:52 ` jvdelisle at gcc dot gnu dot org
  2010-02-27 19:26 ` [Bug fortran/43155] I/O error message: Off-by one position of edit descriptor burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-24  7:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2010-02-24 07:06 -------
(In reply to comment #2)
> Do you intend math, mfh, mth, and nsp to be of type integer or real?

Hmm, good question. The "issue" came about during some IRC chat (#fortran) and
I had/have no access to the whole source code. But it can actually be that the
real code also had "nsp" etc. as INTEGER - at least it was said that gfortran
were choking while ifort were not; whether it should have been real instead, I
don't know.


-- 


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


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

* [Bug fortran/43155] Reading real numbers of the form "123+ 44" (with space)
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-02-24  7:06 ` burnus at gcc dot gnu dot org
@ 2010-02-25  5:52 ` jvdelisle at gcc dot gnu dot org
  2010-02-27 19:26 ` [Bug fortran/43155] I/O error message: Off-by one position of edit descriptor burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2010-02-25  5:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2010-02-25 05:52 -------
Sending        ChangeLog
Sending        io/transfer.c
Transmitting file data ..
Committed revision 157060.

2010-02-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        * io/transfer.c (require_type): Subtract one from item_count for output
        of error message.  Add comment before formatted_transfer function
        explaining why the item_count is off by one.


-- 


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


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

* [Bug fortran/43155] I/O error message: Off-by one position of edit descriptor
  2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-02-25  5:52 ` jvdelisle at gcc dot gnu dot org
@ 2010-02-27 19:26 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-27 19:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2010-02-27 19:26 -------
I think the main problem of comment 0 was a user error - or at least it is not
reproducible with the information we have.

The second problem is solved. I therefore changed the summary and close it as
FIXED.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
            Summary|Reading real numbers of the |I/O error message: Off-by
                   |form "123+ 44" (with space) |one position of edit
                   |                            |descriptor


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


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

end of thread, other threads:[~2010-02-27 19:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-23 20:58 [Bug fortran/43155] New: Reading real numbers of the form "123+ 44" (with space) burnus at gcc dot gnu dot org
2010-02-23 21:28 ` [Bug fortran/43155] " kargl at gcc dot gnu dot org
2010-02-24  2:55 ` jvdelisle at gcc dot gnu dot org
2010-02-24  4:01 ` jvdelisle at gcc dot gnu dot org
2010-02-24  7:06 ` burnus at gcc dot gnu dot org
2010-02-25  5:52 ` jvdelisle at gcc dot gnu dot org
2010-02-27 19:26 ` [Bug fortran/43155] I/O error message: Off-by one position of edit descriptor burnus 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).