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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > IMO this PR should be closed as WONTFIX.
>
> Or document it - a single sentence should be enough.

Well the following patch (untested) "fixes" this PR:

--- ../_clean/gcc/fortran/gfortran.h    2019-02-02 17:23:28.000000000 +0100
+++ gcc/fortran/gfortran.h      2019-02-09 11:17:44.000000000 +0100
@@ -2681,7 +2681,7 @@ typedef struct
   int flag_preprocessed;
   int flag_d_lines;
   int flag_init_integer;
-  int flag_init_integer_value;
+  long int flag_init_integer_value;
   int flag_init_logical;
   int flag_init_character;
   char flag_init_character_value;
@@ -708,7 +708,7 @@ gfc_handle_option (size_t scode, const c

     case OPT_finit_integer_:
       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
-      gfc_option.flag_init_integer_value = atoi (arg);
+      gfc_option.flag_init_integer_value = atol(arg);
       break;

     case OPT_finit_character_:

While playing with the problem I have noticed that if the value in
-finit-integer=N is outside the representable integer, the value is wrapped
around: if N = 128, integer(1) is initialized with -128. IMO this should be
documented.

With the above patch, this is not true for integer(8): if N=Huge(1_8)+1,
integer(8) is initialized with huge(1_8). In addition integer(16) is also
initialized with huge(1_8).

Reply via email to