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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Format contravening f2008   |Format contravening
                   |constraint C1002 permitted  |constraint C1002 permitted

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> The error I found is not just violating a constraint in f2008 or above. 
> The same constraint with different wording is in f2003, f95 and f90.

Agreed, so I removed the reference to f2008 from the summary.

While playing with the patch in comment 4, I saw the following problems:

(1) The behaviors of the frontend and the library are no longer consistent:
  print "(AF9.6)", 'pi =',4*atan(1.0)
is accepted at compile time, but gives an error at runtime.
The error detection should probably be updated in the frontend.

(2) The following tests fail

FAIL: gfortran.dg/comma_format_extension_4.f   -O*  execution test
FAIL: gfortran.dg/dollar_edit_descriptor_2.f   -O*  execution test
FAIL: gfortran.dg/fmt_error_9.f   -O*  execution test
FAIL: gfortran.dg/fmt_g0_5.f08   -O*  execution test
FAIL: gfortran.dg/fmt_t_2.f90   -*0  execution test

I agree with the fixes at

https://gcc.gnu.org/ml/fortran/2018-11/msg00123.html

although I would have added a { dg-options "-std=legacy" } to fmt_t_2.f90.

(3) If the code is compiled with -std=legacy -pedantic, the format is rejected
at runtime (see pr88190).

(4) It looks weird to use compile_options.warn_std instead of
compile_options.allow_std (see pr88190 again).

An alternative patch is

-      /* Assume a missing comma, this is a GNU extension */
-      goto format_item_1;
+      if (compile_options.allow_std & GFC_STD_GNU) 
+        /* Assume a missing comma, this is a GNU extension. */
+        goto format_item_1;
+      format_error (dtp, tail, comma_missing);

PRO

(a) It does not change the behavior for -std=gnu or std=legacy.
(b) It is a simple fix of the above problems that gives the expected errors
with std=f*.

AGAINST

> If you want to allow any constraint violations I think that should be an 
> option, not the default.

It does not fix that. However if this is deemed important by a majority (don't
count me for it, but I won't fight), it would be quite easy to replace
GFC_STD_GNU with GFC_STD_LEGACY where appropriate once pr88190 will be fixed.

Reply via email to