http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59069
Bug ID: 59069 Summary: Bogus error wording for passing array to scalar dummies with user-defined operator Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org The following error message is very misleading. The problem is not the type but that the operands are arrays and the user-defined operator is not elemental: print *, any( many == single ) 1 Error: Operands of comparison operator '==' at (1) are TYPE(latvec)/TYPE(latvec) Found at https://groups.google.com/forum/#!topic/comp.lang.fortran/tuy1wUmVBkY module Overloading implicit none type Latvec integer :: hkl(3) end type Latvec interface operator (==) procedure :: Latvec_equals end interface operator (==) contains pure function Latvec_equals(latvec1, latvec2) result(equals) implicit none type(Latvec), intent(in) :: latvec1, latvec2 logical :: equals equals = all(latvec1%hkl == latvec2%hkl) end function Latvec_equals end module Overloading program Main use Overloading implicit none type(Latvec) :: many(2) = [ Latvec([0,0,1]), Latvec([0,0,2]) ] type(Latvec) :: single = Latvec([0,0,1]) ! these work just fine print *, single == many(1) print *, single == many(2) ! this gives the compilation error: ! Operands of comparison operator '==' at (1) are TYPE(latvec)/TYPE(latvec) print *, any( many == single ) end program Main