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

--- Comment #1 from Harald Anlauf <anlauf at gmx dot de> ---
The problem appears here:

Breakpoint 1, gfc_resolve_cshift (f=0x2431950, array=0x23bc1f0, 
    shift=0x23bc880, dim=0x23bcce0) at ../../trunk/gcc/fortran/iresolve.c:836
836               gfc_resolve_dim_arg (dim);
(gdb) p dim->ts.kind
$1 = 4
(gdb) n
838               if (dim->ts.kind != shift->ts.kind)
(gdb) p dim->ts.kind
$2 = 8
(gdb) l
833             }
834           else
835             {
836               gfc_resolve_dim_arg (dim);
837               /* Convert dim to shift's kind to reduce variations.  */
838               if (dim->ts.kind != shift->ts.kind)
839                 gfc_convert_type_warn (dim, &shift->ts, 2, 0);
840             }
841         }
842

Function gfc_resolve_dim_arg converts the kind and is the cause of the
warning.

The above code points to this rather old commit:

r130391 | jvdelisle | 2007-11-24 01:25:01 +0100 (Sat, 24 Nov 2007) | 20 lines

However, the real point probably is that gfc_index_integer_kind = 8 for -m64,
and gfc_resolve_dim_arg does the conversion from default kind = 4 to the
gfc_index_integer_kind:

  if (dim->ts.kind != gfc_index_integer_kind)
    {
      gfc_typespec ts;

      gfc_clear_ts (&ts);
      ts.type = BT_INTEGER;
      ts.kind = gfc_index_integer_kind;

      gfc_convert_type_warn (dim, &ts, 2, 0);
    }

Deep down the -f(no-)range-check apparently controls whether we get
the warning.

Wouldn't it be better/safer to convert dim/shift to their largest kind
involved?

Reply via email to