https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot 
gnu.org

--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Naturally, every time I have to deal with the error/warning mechanisms, I have
to re-learn it. And, every time, I have to wonder why we do what we do.

In the example, we support L0 as an extension and when seen, it is converted to
a default width of 1.

In the example test case the OP provided the format strings as constant
parameters which allows the compiler to check them at compile time.  The bug is
in how this checking is done and I have a fix for it.

If the strings are changed to variables, they are not checked at compile time
and one must check at run time. For those who may be interested,
philosophically, gfortran tends to avoid unnecessary runtime error messages. In
the given case, L0 will not result in a run time message unless one has used
-pedantic.  Depending on the flag -std= (specified at compile time), the
-pedantic may give a warning or an error.  On error, program execution
terminates. On warning, program execution continues as if nothing happens.

I found the runtime checking of this case not very consistent with the compile
time checking, mostly because the code assumed the unexpected element after the
L was a zero if it was not a positive integer.

I will be submitting a patch to the gfortran list shortly.

As an example, the following does not require -pedantic and will be issued
regardless of the -std= specifier.

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Positive width required with L descriptor
(A,1X,I2,1X,A,1X,I2,1X,A,2(1X,I0,1X),A,2(1X,Lj,1X)) 
                                             ^
Whereas the following with -pedantic by itself:

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime warning: Zero width after L descriptor

and with -pedantic -std=f95:

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Extension: Zero width after L descriptor
(A,1X,I2,1X,A,1X,I2,1X,A,2(1X,I0,1X),A,2(1X,L0,1X))         
                                             ^
Enough said I think.

Reply via email to