From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3881 invoked by alias); 28 Nov 2007 19:06:18 -0000 Received: (qmail 3821 invoked by uid 48); 28 Nov 2007 19:06:07 -0000 Date: Wed, 28 Nov 2007 19:06:00 -0000 Message-ID: <20071128190607.3820.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/34230] Expressions of parameters evaluated with too high precision In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "kargl at gcc dot gnu dot org" 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: 2007-11/txt/msg02814.txt.bz2 ------- Comment #7 from kargl at gcc dot gnu dot org 2007-11-28 19:06 ------- (In reply to comment #6) > I consider this a bug. I have to check, but I think that the IEEE rules are > clear, even though they are not mandatory until we introduce the corresponding > standard modules. The calculation of y does overflow, and while we can debate > on what the behaviour of -fno-range-check should be, I think there is a strong > case for doing the same thing that a) other compilers do, b) IEEE mandates, c) > is what would happen if it occurred at runtime. a) Do other compilers have an equivalent to -fno-range-check? b) The Fortran 95 standard is silent with respect to IEEE-754, and the Fortran 2003 standard only considers IEEE-754 through the explicit use of an intrinsic module. c) Are you suggesting that -ffpe-trap=invalid,overflow,zero should be the default runtime behavior (to match gfortran's default -frange-check behavior)? If you want to be pedantic, this code is invalid real, parameter :: y = exp(log(huge(y))+20) because (See 13.14) A program is prohibited from invoking an intrinsic procedure under circumstances where a value to be returned in a subroutine argument or function result is outside the range of values representable by objects of the specified type and type parameters. unless you're claiming +Inf is in the range of values representable by a real (in which case, you can against remove range checking). If +Inf is a representable value, you need to go fix the IO subsystem to read +Inf (and NaN). character(len=60) str real inf, nan integer, parameter :: i = 2139095040, j = 2141192192 inf = transfer(i,inf) ! Legal, but non-portable nan = transfer(j,nan) ! Legal, but non-portable write(str, *) inf, nan inf = 0 nan = 0 read(str, *) inf, nan print *, inf, nan end troutmask:sgk[246] ./z At line 9 of file a.f90 Fortran runtime error: Bad real number in item 1 of list input You'll also need to fix modules to properly handle +Inf and NaN. module except real, parameter :: inf = 1./0., nan = 0./0. end module program a use except print *, inf, nan end program a troutmask:sgk[251] gfc -o z -fno-range-check a.f90 troutmask:sgk[252] ./z 0.000000 0.000000 -- kargl at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC|kargl at gcc dot gnu dot org|sgk at troutmask dot apl dot | |washington dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34230