http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52024

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-01-28 
20:41:28 UTC ---
With the patch in comment #4 I get

[macbook] f90/bug% gfc pr52024.f90 
pr52024.f90:46.6:

  use m_test
      1
Error: 'i_equal_t' and 't_equal_i' for GENERIC '==' at (1) are ambiguous
pr52024.f90:52.10:

  print *, t == i
          1
Error: Operands of comparison operator '==' at (1) are TYPE(t_test)/INTEGER(4)
pr52024.f90:53.10:

  print *, i == t
          1
Error: Operands of comparison operator '==' at (1) are INTEGER(4)/TYPE(t_test)

instead of

[macbook] f90/bug% gfcp pr52024.f90
pr52024.f90:10.32:

      generic :: operator(==) => t_equal_i, i_equal_t
                                1
Error: 't_equal_i' and 'i_equal_t' for GENERIC '==' at (1) are ambiguous
pr52024.f90:46.6:

  use m_test
      1
Fatal Error: Can't open module file 'm_test.mod' for reading at (1): No such
file or directory

without it. However the following test


module m_sort
  implicit none
  type, abstract :: sort_t
  contains
    generic :: operator(.gt.) => gt_cmp
    procedure :: gt_cmp
    end type sort_t
contains
  logical function gt_cmp(a,b)
    class(sort_t), intent(in) :: a, b
    gt_cmp = .true.
  end function gt_cmp
end module

module test
  use m_sort
  implicit none
  type, extends(sort_t) :: sort_int_t
    integer :: i
  contains
    generic :: operator(.gt.) => gt_cmp_int
    procedure :: gt_cmp_int
  end type
contains
  logical function gt_cmp_int(a,b) result(cmp)
    class(sort_int_t), intent(in) :: a, b
    if (a%i > b%i) then
      cmp = .true.
     else
      cmp = .false.
     end if
  end function gt_cmp_int
end module

(related to pr41951, but I cannot find where I grabbed it) now gives an ICE

[macbook] f90/bug% gfc pr41951_3.f90
f951: internal compiler error: in check_generic_tbp_ambiguity, at
fortran/resolve.c:10965
...

instead of the error

[macbook] f90/bug% gfcp pr41951_3.f90
pr41951_3.f90:21.32:

    generic :: operator(.gt.) => gt_cmp_int
                                1
Error: 'gt_cmp_int' and 'gt_cmp' for GENERIC '.gt.' at (1) are ambiguous

Note that AFAICT the other tests in pr41951 don't ICE.

Reply via email to