From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30699 invoked by alias); 16 May 2011 21:28:50 -0000 Received: (qmail 30689 invoked by uid 22791); 16 May 2011 21:28:50 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_SG 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; Mon, 16 May 2011 21:28:36 +0000 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49010] Result of MOD and MODULO intrinsic has wrong sign X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu 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: Mon, 16 May 2011 21:29: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-05/txt/msg01284.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49010 --- Comment #3 from Steve Kargl 2011-05-16 21:17:44 UTC --- There is an additional problem with MOD(A,P) and MODULO(A,P). In F95, one finds "P = 0, the result is processor dependent." In F2003 and F2008, one finds "P shall not be zero." Consider the code, program foo real, parameter :: b = 0. real a, p, m1, m2 a = 2. p = 0. m1 = mod(a, p) m2 = mod(a, b) print *, m1, m2 end program foo with the __builtin_fmod function we get troutmask:sgk[215] gfc4x -o z t.f90 && ./z NaN NaN (ie., there is no error or warning that P=0). If we simply eliminate the __builtin_fmod function, we get troutmask:sgk[212] gfc4x -o z t.f90 && ./z 2.00000000 2.00000000 which is worse than the NaN. :( __ Steve