[Bug fortran/64432] [5 Regression] SYSTEM_CLOCK(COUNT_RATE=rate) wrong result for integer(4)::rate

anlauf at gmx dot de gcc-bugzilla@gcc.gnu.org
Wed Feb 18 20:04:00 GMT 2015


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

--- Comment #22 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Jerry DeLisle from comment #21)
> Created attachment 34798 [details]
> Full Patch
> 
> This patch attempts to do it all. I have not tested the mingw/cygwin side of
> it.
> 
> Any testing/comments welcome

Jerry,

I did some simple test and found the following:

Cases with a single argument present:

% cat gfcbug128f.f90
program gfcbug128e
  integer(1) :: count_rate_i1, count_max_i1, count_i1
  integer(2) :: count_rate_i2, count_max_i2, count_i2
  integer(4) :: count_rate_i4, count_max_i4, count_i4
  integer(8) :: count_rate_i8, count_max_i8, count_i8
  real(4)    :: count_rate_r4 = 0
  real(8)    :: count_rate_r8 = 0

  print *, "KIND=1:"
  call system_clock (count=count_i1)
  print *, "count     =",count_i1
  call system_clock (count_max=count_max_i1)
  print *, "count_max =", count_max_i1
  call system_clock (count_rate=count_rate_i1)
  print *, "count_rate=", count_rate_i1
  print *
  print *, "KIND=2:"
  call system_clock (count=count_i2)
  print *, "count     =",count_i2
  call system_clock (count_max=count_max_i2)
  print *, "count_max =", count_max_i2
  call system_clock (count_rate=count_rate_i2)
  print *, "count_rate=", count_rate_i2
  print *
  print *, "KIND=4:"
  call system_clock (count=count_i4)
  print *, "count     =",count_i4
  call system_clock (count_max=count_max_i4)
  print *, "count_max =", count_max_i4
  call system_clock (count_rate=count_rate_i4)
  print *, "count_rate=", count_rate_i4
  call system_clock (count_rate=count_rate_r4)
  print *, "count_rate_real=", count_rate_r4
  print *
  print *, "KIND=8:"
  call system_clock (count=count_i8)
  print *, "count     =",count_i8
  call system_clock (count_max=count_max_i8)
  print *, "count_max =", count_max_i8
  call system_clock (count_rate=count_rate_i8)
  print *, "count_rate=", count_rate_i8
  call system_clock (count_rate=count_rate_r8)
  print *, "count_rate_real=", count_rate_r8
end

Test output:
 KIND=1:
 count     =  116
 count_max =  127
 count_rate=    1

 KIND=2:
 count     =  27083
 count_max =  32767
 count_rate=   1000

 KIND=4:
 count     =   507374028
 count_max =  2147483647
 count_rate=        1000
 count_rate_real=   1000.00000    

 KIND=8:
 count     =     1424289032652253
 count_max =  9223372036854775807
 count_rate=              1000000
 count_rate_real=   1000000.0000000000     

Looks reasonable so far, assuming it behaves as (to be) documented.

Further tests with two arguments:

% cat gfcbug128g.f90
program gfcbug128g
  integer(1) :: count_rate_i1, count_max_i1, count_i1
  integer(2) :: count_rate_i2, count_max_i2, count_i2
  integer(4) :: count_rate_i4, count_max_i4, count_i4
  integer(8) :: count_rate_i8, count_max_i8, count_i8
  real(4)    :: count_rate_r4 = 0
  real(8)    :: count_rate_r8 = 0

  call system_clock (count=count_i1,count_max=count_max_i2)
  print *, "count(1),count_max(2) =",count_i1, count_max_i2
  call system_clock (count=count_i2,count_max=count_max_i1)
  print *, "count(2),count_max(1) =",count_i2, count_max_i1
  call system_clock (count=count_i4,count_max=count_max_i2)
  print *, "count(4),count_max(2) =",count_i4, count_max_i2
  call system_clock (count=count_i2,count_max=count_max_i4)
  print *, "count(2),count_max(4) =",count_i2, count_max_i4
  call system_clock (count=count_i4,count_max=count_max_i8)
  print *, "count(4),count_max(8) =",count_i4, count_max_i8
  call system_clock (count=count_i8,count_max=count_max_i4)
  print *, "count(8),count_max(4) =",count_i8, count_max_i4
  call system_clock (count=count_i1,count_max=count_max_i8)
  print *, "count(1),count_max(8) =",count_i1, count_max_i8
  call system_clock (count=count_i8,count_max=count_max_i1)
  print *, "count(8),count_max(1) =",count_i8, count_max_i1

  call system_clock (count_rate=count_rate_i1,count_max=count_max_i2)
  print *, "count_rate(1),count_max(2) =",count_rate_i1, count_max_i2
  call system_clock (count_rate=count_rate_i2,count_max=count_max_i1)
  print *, "count_rate(2),count_max(1) =",count_rate_i2, count_max_i1
  call system_clock (count_rate=count_rate_i4,count_max=count_max_i2)
  print *, "count_rate(4),count_max(2) =",count_rate_i4, count_max_i2
  call system_clock (count_rate=count_rate_i2,count_max=count_max_i4)
  print *, "count_rate(2),count_max(4) =",count_rate_i2, count_max_i4
  call system_clock (count_rate=count_rate_i4,count_max=count_max_i8)
  print *, "count_rate(4),count_max(8) =",count_rate_i4, count_max_i8
  call system_clock (count_rate=count_rate_i8,count_max=count_max_i4)
  print *, "count_rate(8),count_max(4) =",count_rate_i8, count_max_i4
  call system_clock (count_rate=count_rate_i1,count_max=count_max_i8)
  print *, "count_rate(1),count_max(8) =",count_rate_i1, count_max_i8
  call system_clock (count_rate=count_rate_i8,count_max=count_max_i1)
  print *, "count_rate(8),count_max(1) =",count_rate_i8, count_max_i1
end

Test output:

 count(1),count_max(2) =   11    127
 count(2),count_max(1) =     11  127
 count(4),count_max(2) =        5991  32767
 count(2),count_max(4) =   5991       32767
 count(4),count_max(8) =   507909991           2147483647
 count(8),count_max(4) =            507909991  2147483647
 count(1),count_max(8) =   11                  127
 count(8),count_max(1) =                   11  127
 count_rate(1),count_max(2) =    1    127
 count_rate(2),count_max(1) =      1  127
 count_rate(4),count_max(2) =        1000  32767
 count_rate(2),count_max(4) =   1000       32767
 count_rate(4),count_max(8) =        1000           2147483647
 count_rate(8),count_max(4) =                 1000  2147483647
 count_rate(1),count_max(8) =    1                  127
 count_rate(8),count_max(1) =                    0  127

OK, but the last line looks strange: lacking documentation,
I'd expect the rate to be 1, not 0.  (Not that I'd use that
in real code...).

Cheers,
Harald



More information about the Gcc-bugs mailing list