Code Comments
Programming Forum and web based access to our favorite programming groups.I use the following well-known trick for my numeric kinds: integer, parameter, public :: sp = kind(1.0) integer, parameter, public :: dp = selected_real_kind(2*precision(1.0_sp)) integer, parameter, public :: qp_preferred = & selected_real_kind(2*precision(1.0_dp)) integer, parameter, public :: qp = (1+sign(1,qp_preferred))/2*qp_preferred+ & (1-sign(1,qp_preferred))/2*dp When i compile using the latest gfortran on Linux (4.3.0 20070824) i get: gfortran -c -g -pedantic -Wall -Wimplicit-interface -Wunderflow -fbounds-che ck -fimplicit-none -std=f95 numeric_kinds.f95 numeric_kinds.f95:31.44: (1-sign(1,qp_preferred))/2*dp 1 Error: Extension: Evaluation of nonstandard initialization expression at (1) numeric_kinds.f95:37.45: (1-sign(1,qp_preferred))/2*dp 1 Error: Extension: Evaluation of nonstandard initialization expression at (1) Is this indeed an error or is gfortran wrong here? I've been using this trick for a long time and it is the first time that a compiler complains about it... Thanks, Bart -- "Share what you know. Learn what you don't."
Post Follow-up to this messageHi, On Aug 24, 5:41 pm, Bart Vandewoestyne <MyFirstName.MyLastN...@telenet.be> wrote: > (1-sign(1,qp_preferred))/2*dp > 1 > Error: Extension: Evaluation of nonstandard initialization expression at ( 1) > numeric_kinds.f95:37.45: > > Is this indeed an error or is gfortran wrong here? I've been using this > trick for a long time and it is the first time that a compiler complains > about it... There are two bugs here: a) As it is accepted with -std=f2003 it should have been "Error: Fortran 2003" b) The message itself is wrong: Fortran 95 has: "An initialization expression is a constant expression in which the exponentiation operation is permitted only with an integer power, and each primary is [...] (4) An elemental intrinsic function reference of type integer or character where each argument is an initialization expression of type integer or character," Thus SIGN with INTEGER arguments if Fortran 95 and with REAL arguments it is Fortran 2003: "An initialization expression is an expression [...] in which each operation is intrinsic, and each primary is [...] (4) A reference to an elemental standard intrinsic function, where each argument is an initialization expression [...] 13.7.109 SIGN (A, B) [...] Class. Elemental function." Filled as bugreport: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33178 Thanks for spotting the bug. Tobias PS: The workaround is to use "-std=f2003".
Post Follow-up to this messagePost script: On 24 Aug., 18:01, Tobias Burnus <bur...@net-b.de> wrote: > There are two bugs here: > a) As it is accepted with -std=f2003 it should have been "Error: > Fortran 2003" > b) The message itself is wrong: The two bugs have been fixed. (b) was a regression with regards to gfortran 4.2.x. (The problem was the check for the argument being of the type integer used the the wrong variable.) Thanks for the bug report. Tobias
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.