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

--- Comment #5 from G. Steinmetz <gs...@t-online.de> ---

Looking again at intrinsic "max" and a variant of z1/z2 :

$ cat z6.f90
program p
   character :: max
   print *, max(1.0, 2.0)
end

$ gfortran-9-20181028 z6.f90
f951: internal compiler error: gfc_convert_constant(): Unexpected type


$ cat z7.f90
program p
   character :: max = 'c'
   print *, max(1.0, 2.0)
end

$ gfortran-9-20181028 z7.f90
z7.f90:2:19:

    2 |    character :: max = 'c'
      |                   1
Error: Function 'max' at (1) cannot have an initializer
z7.f90:2:19:

    2 |    character :: max = 'c'
      |                   1
Error: 'max' at (1) is not a VALUE


$ cat z7b.f90
program p
   character :: max
   print *, max(1.0, 2.0)
   max = 'c'
   print *, max
end

$ gfortran-9-20181028 z7b.f90
z7b.f90:4:6:

    4 |    max = 'c'
      |      1
Error: 'max' at (1) is not a variable
z7b.f90:5:15:

    5 |    print *, max
      |               1
Error: Function 'max' requires an argument list at (1)


---

With a user-defined type instead of an intrinsic type this happens :


$ cat zm1.f90
program p
   type t
      character :: c = 'c'
   end type
   type(t) :: max
   print *, max(1, 2)
end

$ gfortran-9-20181028 zm1.f90
f951: internal compiler error: gfc_convert_constant(): Unexpected type


$ cat zm2.f90
program p
   type t
      character :: c = 'c'
   end type
   type(t) :: max(3)
   print *, max(1, 2)
end

$ gfortran-9-20181028 zm2.f90
zm2.f90:6:15:

    6 |    print *, max(1, 2)
      |               1
Error: Rank mismatch in array reference at (1) (2/1)


$ cat zm3.f90
program p
   type t
      character :: c = 'c'
   end type
   type(t) :: max(3, 3)
   print *, max(1, 2)
end

$ gfortran-9-20181028 -Wall -Wextra -fcheck=all zm3.f90
$ a.out
 c


BTW, thanks for working on this issue.

Reply via email to