public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008
@ 2011-04-27  6:27 thenlich at users dot sourceforge.net
  2011-04-27  7:03 ` [Bug libfortran/48785] " burnus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-04-27  6:27 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: BOZ editing of real numbers not working with
                    -std=f2008
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thenlich@users.sourceforge.net


The B, O and Z edit descriptors are not accepted for output of real numbers
when Fortran 2008 standard mode is selected.

Fortran 2008 explicitly allows B, O and Z editing for real and complex numbers.
(This is different from Fortran 2003, which only specifies B, O and Z editing
for integer numbers. This has been discussed in Bug 41711.)

10.7.2.4 B, O, and Z editing
1 [...] The corresponding input/output list item shall be of type integer,
real, or complex.
...
4 The value is INT (X) if the input list item is of type integer and REAL (X)
if the input list item is of type real or complex, where X is a
boz-literal-constant that specifies the same bit sequence as the digits of the
input field.

The following program, when compiled with "-std=f2008" fails with:

                                                         1111011
At line 3 of file test_boz.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Expected INTEGER for item 1 in formatted transfer, got
REAL
(b64)
 ^

program test_boz
    print "(b64)", 123
    print "(b64)", 1.23
    print "(b0)", 123
    print "(b0)", 1.23
    print "(o24)", 123
    print "(o24)", 1.23
    print "(o0)", 123
    print "(o0)", 1.23
    print "(z0)", 123
    print "(z0)", 1.23
    print "(z16)", 123
    print "(z16)", 1.23

    print "(b64.64)", 123
    print "(b64.64)", 1.23
    print "(b0.64)", 123
    print "(b0.64)", 1.23
    print "(o24.24)", 123
    print "(o24.24)", 1.23
    print "(o0.24)", 123
    print "(o0.24)", 1.23
    print "(z0.16)", 123
    print "(z0.16)", 1.23
    print "(z16.16)", 123
    print "(z16.16)", 1.23
end program test_boz

The expected behavior is the same as without the "-std=f2008" option. The
program should output:
                                                         1111011
                                  111111100111010111000010100100
1111011
111111100111010111000010100100
                     173
              7747270244
173
7747270244
7B
3F9D70A4
              7B
        3F9D70A4
0000000000000000000000000000000000000000000000000000000001111011
0000000000000000000000000000000000111111100111010111000010100100
0000000000000000000000000000000000000000000000000000000001111011
0000000000000000000000000000000000111111100111010111000010100100
000000000000000000000173
000000000000007747270244
000000000000000000000173
000000000000007747270244
000000000000007B
000000003F9D70A4
000000000000007B
000000003F9D70A4


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
@ 2011-04-27  7:03 ` burnus at gcc dot gnu.org
  2011-05-02 13:04 ` thenlich at users dot sourceforge.net
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-04-27  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |jvdelisle at gcc dot
                   |                            |gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-04-27 06:55:48 UTC ---
In libgfortran/io/transfer.c's one currently has in
formatted_transfer_scalar_read and formatted_transfer_scalar_write code such as

    case FMT_B:
      if (n == 0)
        goto need_data;
      if (!(compile_options.allow_std & GFC_STD_GNU)
              && require_type (dtp, BT_INTEGER, type, f))
        return;
      write_b (dtp, f, p, kind);
      break;

s/GFC_STD_GNU/GFC_STD_F2008/ should take care of that. However, that might
accept too much, namely CHARACTER and LOGICAL, which are excluded at: "The
corresponding input/output list item shall be of type integer, real, or
complex."

I don't know whether we should care - I tend to be more liberal for run-time
diagnostic than for compile-time diagnostic ...


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
  2011-04-27  7:03 ` [Bug libfortran/48785] " burnus at gcc dot gnu.org
@ 2011-05-02 13:04 ` thenlich at users dot sourceforge.net
  2011-05-02 13:08 ` jvdelisle at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-02 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-05-02 12:58:42 UTC ---
Created attachment 24162
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24162
Proposed patch for input/output


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
  2011-04-27  7:03 ` [Bug libfortran/48785] " burnus at gcc dot gnu.org
  2011-05-02 13:04 ` thenlich at users dot sourceforge.net
@ 2011-05-02 13:08 ` jvdelisle at gcc dot gnu.org
  2011-05-02 13:15 ` thenlich at users dot sourceforge.net
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-05-02 13:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-05-02 13:06:53 UTC ---
Thanks Thomas, thanks for support.  I will have a close look and check tonight.


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2011-05-02 13:08 ` jvdelisle at gcc dot gnu.org
@ 2011-05-02 13:15 ` thenlich at users dot sourceforge.net
  2011-05-02 13:45 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-02 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-05-02 13:01:33 UTC ---
Created attachment 24163
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24163
Test case for input/output of real numbers with B/O/Z editing


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (3 preceding siblings ...)
  2011-05-02 13:15 ` thenlich at users dot sourceforge.net
@ 2011-05-02 13:45 ` burnus at gcc dot gnu.org
  2011-05-02 14:11 ` thenlich at users dot sourceforge.net
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-02 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-02 13:40:29 UTC ---
(In reply to comment #2)
> Created attachment 24162 [details]
> Proposed patch for input/output

-      if (!(compile_options.allow_std & GFC_STD_GNU)
+      if (!(compile_options.allow_std & (GFC_STD_GNU | GFC_STD_F2008))

As mentioned in comment 1, replacing GFC_STD_GNU by GFC_STD_F2008 should be
sufficient without OR-ing the two.


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (4 preceding siblings ...)
  2011-05-02 13:45 ` burnus at gcc dot gnu.org
@ 2011-05-02 14:11 ` thenlich at users dot sourceforge.net
  2011-05-02 14:36 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-02 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-05-02 14:10:22 UTC ---
Can you elaborate on this?

Previously we allowed the format with -std=gnu.

Now we want to allow it with -std=gnu or -std=f2008. So we call require_type()
only if neither of these options is set.

That's why I changed the mask from GFC_STD_GNU to (GFC_STD_GNU |
GFC_STD_F2008).

And the values have different bits set, so the OR is not redundant:

#define GFC_STD_F2008        (1<<7)    /* New in F2008.  */
#define GFC_STD_LEGACY        (1<<6)    /* Backward compatibility.  */
#define GFC_STD_GNU        (1<<5)    /* GNU Fortran extension.  */


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (5 preceding siblings ...)
  2011-05-02 14:11 ` thenlich at users dot sourceforge.net
@ 2011-05-02 14:36 ` burnus at gcc dot gnu.org
  2011-05-02 15:14 ` thenlich at users dot sourceforge.net
  2013-01-02 20:03 ` jvdelisle at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-02 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-02 14:31:56 UTC ---
(In reply to comment #6)
> Can you elaborate on this?
> That's why I changed the mask from GFC_STD_GNU to (GFC_STD_GNU |
> GFC_STD_F2008).

First, the code is/should be also allowed for -std=legacy (GFC_STD_LEGACY).

Secondly, the point is not that GFC_STD_GNU and GFC_STD_F2008 are same (they
obviously aren't), but that

having      (compile_options.allow_std | GFC_STD_F2008) != 0
 => implies (compile_options.allow_std | GFC_STD_GNU) != 0

which is a property of "allow_std". See gcc/fortran/options.c:

    case OPT_std_f2003:
      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
    | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
    case OPT_std_f2008:
      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
    | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
    case OPT_std_gnu:
      set_default_std_flags ();
      break;


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (6 preceding siblings ...)
  2011-05-02 14:36 ` burnus at gcc dot gnu.org
@ 2011-05-02 15:14 ` thenlich at users dot sourceforge.net
  2013-01-02 20:03 ` jvdelisle at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-02 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-05-02 15:12:06 UTC ---
(In reply to comment #7)

O, I see. The important part is in
set_default_std_flags (void)
{
  gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
    | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
    | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY;
  gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
}

So technically, we only need to test for GFC_STD_F2008, just as you said.


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

* [Bug libfortran/48785] BOZ editing of real numbers not working with -std=f2008
  2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
                   ` (7 preceding siblings ...)
  2011-05-02 15:14 ` thenlich at users dot sourceforge.net
@ 2013-01-02 20:03 ` jvdelisle at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-01-02 20:03 UTC (permalink / raw)
  To: gcc-bugs


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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

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

--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2013-01-02 20:02:51 UTC ---
Looking at transfer.c and trying the test case provided here, I believe this is
fixed.

Closing.


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

end of thread, other threads:[~2013-01-02 20:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27  6:27 [Bug libfortran/48785] New: BOZ editing of real numbers not working with -std=f2008 thenlich at users dot sourceforge.net
2011-04-27  7:03 ` [Bug libfortran/48785] " burnus at gcc dot gnu.org
2011-05-02 13:04 ` thenlich at users dot sourceforge.net
2011-05-02 13:08 ` jvdelisle at gcc dot gnu.org
2011-05-02 13:15 ` thenlich at users dot sourceforge.net
2011-05-02 13:45 ` burnus at gcc dot gnu.org
2011-05-02 14:11 ` thenlich at users dot sourceforge.net
2011-05-02 14:36 ` burnus at gcc dot gnu.org
2011-05-02 15:14 ` thenlich at users dot sourceforge.net
2013-01-02 20:03 ` jvdelisle at gcc dot gnu.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).