From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23160 invoked by alias); 5 May 2014 23:30:48 -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 23127 invoked by uid 55); 5 May 2014 23:30:44 -0000 From: "tristanmoody at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61069] Gfortran allows functions to be called as subroutines when defined in a separate source file Date: Mon, 05 May 2014 23:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tristanmoody at gmail dot com 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: Message-ID: In-Reply-To: References: 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: 2014-05/txt/msg00315.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61069 --- Comment #2 from Tristan Moody --- Of course the code is invalid. That's the point. The compiler is inconsistent about whether it will catch that fact. This invalid code could easily show up, say, when refactoring a large code base, converting a subroutine to a function, wherein a subroutine call gets missed. Since this is a case of the compiler treating invalid code as valid and not the reverse, a fix is low priority, if not unnecessary. I just think it should, at the very least, be noted in the documentation. For what it's worth, neither the Intel nor the Portland compilers detected that the code was invalid, even when everything was in a single source file. On May 5, 2014 5:33 PM, "dominiq at lps dot ens.fr" < gcc-bugzilla@gcc.gnu.org> wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61069 > > --- Comment #1 from Dominique d'Humieres --- > Your code is invalid and the compiler can do anything. Note that if you > type > bar as you should, gfortran complains: > > ! { dg-do compile } > program foo > implicit none > integer :: i, bar > external bar, baz > > i = 0 > call bar(i) > ! print *, bar(i) > call baz(i) > end program > > gives > > pr61069_3.f90:4.19: > > integer :: i, bar > 1 > Error: FUNCTION attribute conflicts with SUBROUTINE attribute in 'bar' at > (1) > pr61069_3.f90:4.19: > > integer :: i, bar > 1 > pr61069_3.f90:8.13: > > call bar(i) > 2 > Error: 'bar' at (1) has a type, which is not consistent with the CALL at > (2) > > -- > You are receiving this mail because: > You reported the bug. >