Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

gfortran bug or not?
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."

Report this thread to moderator Post Follow-up to this message
Old Post
Bart Vandewoestyne
08-25-07 12:12 AM


Re: gfortran bug or not?
Hi,

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".


Report this thread to moderator Post Follow-up to this message
Old Post
Tobias Burnus
08-25-07 12:12 AM


Re: gfortran bug or not?
Post 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


Report this thread to moderator Post Follow-up to this message
Old Post
Tobias Burnus
08-25-07 12:12 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:08 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.