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

--- Comment #1 from Harald Anlauf <anlauf at gmx dot de> ---
Modifying the test code as follows:

% cat gfcbug128b.f90
program gfcbug128b
  integer(4) :: count_rate, count_max
  call system_clock (count_rate=count_rate,count_max=count_max)
  call system_clock (count_rate=count_rate)
  call system_clock (count_max=count_max)
end

% head -12 gfcbug128b.f90.003t.original
gfcbug128b ()
{
  integer(kind=4) count_max;
  integer(kind=4) count_rate;

  {
    integer(kind=8) count_rate.0;

    _gfortran_system_clock_4 (0B, &count_rate, &count_max);
    _gfortran_system_clock_8 (0B, &count_rate.0, 0B);
    count_rate = (integer(kind=4)) count_rate.0;
    _gfortran_system_clock_4 (0B, 0B, &count_max);

shows that the logic in trans-intrinsic.c::conv_intrinsic_system_clock
does not cover the case of single arguments:


  gfc_expr *count = code->ext.actual->expr;
  gfc_expr *count_rate = code->ext.actual->next->expr;
  gfc_expr *count_max = code->ext.actual->next->next->expr;

  /* The INTEGER(8) version has higher precision, it is used if both COUNT
     and COUNT_MAX can hold 64-bit values, or are absent.  */
  if ((!count || count->ts.kind >= 8)
      && (!count_max || count_max->ts.kind >= 8))
    kind = 8;
  else
    kind = gfc_default_integer_kind;
  type = gfc_get_int_type (kind);

  /* Evaluate our arguments.  */


This probably needs to be amended.

Reply via email to