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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
As shown by pr64138 and the links therein, disambiguation of procedures by
argument position is tricky. This does not change the fact that the behavior
should be the same for, e.g., 'lle' and '<='. Also the following code

module m_string
  implicit none

  type t_string
      character, dimension(:), allocatable :: buffer
      integer :: length = 0
      integer :: size = 0

    contains

!     Interfaces for string types
      generic :: character => string_to_char
      procedure :: string_to_char

!     Element comparison operators
      procedure :: string_less_equal_char
      procedure, pass(right1) :: char_less_equal_string
      generic :: operator(<=) => string_less_equal_char, &
                                 char_less_equal_string

!     Character compatibility interfaces      
      generic :: lle => string_less_equal_char, &
                        char_less_equal_string

    end type t_string

contains

! Return the string as character
pure function string_to_char( this ) result(res)
  class(t_string), intent(in) :: this
  character(len=this%size) :: res
  if( allocated(this%buffer) ) then
    res = transfer( this%buffer(:this%size), res )
  else
    res = ''
  end if
end function string_to_char

! Comparison operator 'string <= character'
elemental function string_less_equal_char( left, right ) result(res)
  class(t_string), intent(in) :: left
  character(len=*), intent(in) :: right
  logical :: res
  res = ( left%character() <= right )
end function string_less_equal_char

! Comparison operator 'character <= string'
elemental function char_less_equal_string( left1, right1 ) result(res)
  character(len=*), intent(in) :: left1
  class(t_string), intent(in) :: right1
  logical :: res
  res = ( left1 <= right1%character() )
end function char_less_equal_string

end module m_string

still gives

Error: 'string_less_equal_char' and 'char_less_equal_string' for GENERIC 'lle'
at (1) are ambiguous

Reply via email to