From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20871 invoked by alias); 19 Jan 2011 20:44:52 -0000 Received: (qmail 20862 invoked by uid 22791); 19 Jan 2011 20:44:51 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Jan 2011 20:44:45 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47359] Recursive functions of intrinsic names generates invalid assembler X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 19 Jan 2011 20:53:00 -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 X-SW-Source: 2011-01/txt/msg01961.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47359 --- Comment #1 from Dominique d'Humieres 2011-01-19 20:44:27 UTC --- > I know this is sort of a contrived case but seems that gfortran is getting > confused in this case leading to syntactically invalid assembler. I don't see the invalid assembler on x86_64-apple-darwin10 and powerpc-apple-darwin9 for trunk (4.6), 4.50, and 4.4.4. However gfortran is indeed confused by the code as shown by the following modification: RECURSIVE FUNCTION MAX(A, B, i) RESULT(K) real i i = i + 1 IF (B >= 0) THEN K = MAX(A+1, B-1, i) ELSE K = A END IF END RECURSIVE FUNCTION myMAX(A, B, i) RESULT(K) real i i = i + 1 IF (B >= 0) THEN K = myMAX(A+1, B-1, i) ELSE K = A END IF END external max a = 0 b = 0 i = max(3.2,0.2, a) j = mymax(3.2,0.2, b) print *, i, j, a, b a = 0 b = 0 i = max(3.2,2.2, a) j = mymax(3.2,2.2, b) print *, i, j, a, b end [macbook] f90/bug% gfc pr47359_db_3.f90 [macbook] f90/bug% a.out 4 4 1.0000000 2.0000000 4 6 1.0000000 4.0000000 where I had to declare 'i' REAL in order to avoid a compilation error and clearly the external MAX is called, but only once apparently because the call to MAX in MAX is a call to the intrinsic. g95 gives 4 4 2. 2. 6 6 4. 4.