From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24121 invoked by alias); 10 Nov 2013 17:51:42 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 24087 invoked by uid 48); 10 Nov 2013 17:51:39 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59069] New: Bogus error wording for passing array to scalar dummies with user-defined operator Date: Sun, 10 Nov 2013 17:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg00945.txt.bz2 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