[Bug fortran/88052] Format contravening f2008 constraint C1002 permitted

jvdelisle at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Nov 17 18:18:00 GMT 2018


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

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to john.harper from comment #0)
--- snip ---
> 
> If the second print statement is changed to
>   print "(AF9.6)",'pi =',4*atan(1.0)
> then the error is correctly diagnosed.

Note that in the latter case that is diagnosed correctly, the format string is
a constant set at compile time and so we can check it at compile time.

In the case where the format string is a variable expression the front end may
or may not know what its value is at the time of execution. A user could just
as well have computed the expression.

I suppose at compile time there may be a way to see if the expression has been
set to a constant string but to do this would require some sort of dependency
analysis.

Because of this complexity we fall back to doing checks at run time just before
the string is used as part of the READ or WRITE operations.

Changing the runtime behaviour to give a runtime warning with -std=f2008 should
be straightforward.


More information about the Gcc-bugs mailing list