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

            Bug ID: 96686
           Summary: MIN/MAX should reject character arguments of different
                    kind rather than ICE
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

We current fail on this:

program p
  implicit none
  character(kind=1) :: c1 = "1"
  character(kind=4) :: c4 = 4_"4"
  print *, min (c1, c4)
end program p

min_max_char.f90:5:16:

    5 |   print *, min (c1, c4)
      |                1
internal compiler error: Cannot convert 'CHARACTER(1)' to 'CHARACTER(0,4)' at
(1)
0x69ee19 gfc_report_diagnostic
        ../../gcc-trunk/gcc/fortran/error.c:782
0x6a0592 gfc_internal_error(char const*, ...)
        ../../gcc-trunk/gcc/fortran/error.c:1402
0x6bfb68 gfc_convert_type_warn(gfc_expr*, gfc_typespec*, int, int, bool)
        ../../gcc-trunk/gcc/fortran/intrinsic.c:5350
0x6c8385 gfc_resolve_minmax
        ../../gcc-trunk/gcc/fortran/iresolve.c:1621
0x6b4391 resolve_intrinsic
        ../../gcc-trunk/gcc/fortran/intrinsic.c:4501
0x6b4391 do_simplify
        ../../gcc-trunk/gcc/fortran/intrinsic.c:4671
0x6bedda gfc_intrinsic_func_interface(gfc_expr*, int)
        ../../gcc-trunk/gcc/fortran/intrinsic.c:5013
0x70e17b resolve_unknown_f
        ../../gcc-trunk/gcc/fortran/resolve.c:2919
0x70e17b resolve_function
        ../../gcc-trunk/gcc/fortran/resolve.c:3277
0x70e17b gfc_resolve_expr(gfc_expr*)
        ../../gcc-trunk/gcc/fortran/resolve.c:7094
0x714e84 gfc_resolve_expr(gfc_expr*)
        ../../gcc-trunk/gcc/fortran/resolve.c:7061
0x714e84 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:11799
0x71e09f gfc_resolve_blocks(gfc_code*, gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:10826
0x713c58 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:11789
0x71650d resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.c:17334
0x7165de gfc_resolve(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.c:17369
0x6fe4b5 resolve_all_program_units
        ../../gcc-trunk/gcc/fortran/parse.c:6286
0x6fe4b5 gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:6538
0x74b3af gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:212

Proposed solution: since MIN/MAX with character arguments are not legacy stuff,
there is no good reason to provide a GNU extension.  We should simply reject
this always, as in:

gfc-11 min_max_char.f90 -std=f2018
min_max_char.f90:5:20:

    5 |   print *, min (c1, c4)
      |                    1
Error: GNU Extension: Different type kinds at (1)

although it should simply say: Different type kinds.  No reference to any
GNU Extension.

Reply via email to