[Bug fortran/95053] [11 regression] ICE in f951: gfc_divide()

anlauf at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 14 06:04:21 GMT 2020


--- Comment #20 from anlauf at gcc dot gnu.org ---
(In reply to Bill Seurer from comment #19)
> There's some stuff above this in the module but this is the part that shows
> the error and I think it contains all the declarations.
> subroutine Z()
>    real(r8) :: cld(99,99)
>    real(r8) cldeps
>    parameter (cldeps = 0.0_r8)
>    real(r8) asort(99)
>    if (cldeps > 0) then
>       asort(1) = 1.0_r8-(floor(cld(1,7)/cldeps)*cldeps)
>    endif
>    return
> end subroutine Z
>    15 |       asort(1) = 1.0_r8-(floor(cld(1,7)/cldeps)*cldeps)
>       |                                              1
> Error: Division by zero at (1)

Thanks for the small example.

The parameter statement makes cldeps to a constant that is zero when that
line is processed.  Arguably that is borderline code.

I see two ways around:

1) either replace the parameter statement for cldeps by an initialization:

  data cldeps / 0.0_r8 /

2) or add -fno-range-check to the command line.

I could adjust the error message so that you get an approprate hint
how to switch off that error.

What do you think?

More information about the Gcc-bugs mailing list