This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fortran] Committed fix for FLOAT intrinsics


On Wed, Mar 29, 2006 at 11:44:17AM +0200, Manfred Schwarb wrote:
> Brooks,
> 
>>> Steve Kargl wrote: 
>>> 
>>> I've committed the following patch under the "Obviously
>>> correct" rule to both trunk (3 days ago) and 4.1 (today).
>>> This fixes a regression with respect to g77.
>>> [...] 
>>> 
>>> +@node FLOAT
>>> +@section @code{FLOAT} --- Convert integer to default real
>>> +@findex @code{FLOAT} intrinsic
>>> +@cindex floor
>>> +
>>> +@table @asis
>>> +@item @emph{Description}:
>>> +@code{FLOAT(I)} converts the integer @var{I} to a default real value.
>> 
>> It also occurs to me that this should probably reference the standard's
>> REAL function, which provides a superset of the same functionality.
>> 
>> Perhaps add the following to the end of the extant description:
>> "This non-standard intrinsic is provided for compatibility with
>> legacy code. New code should use the standard @code{REAL} intrinsic."
>> 
> 
> This is not a standard vs. non-standard question.

Actually, it is a standard vs non-standard question as well as
backwards compatibility with g77.

> FLOAT is very much standard Fortran77.
> Fortran has the concept of "Generic Names" and "Specific Names" 
> for intrinsics.
> For this case, REAL is the generic name, and REAL, FLOAT and SNGL
> are the corresponding specific names.

The above is indeed correct with the caveat that the argument
to FLOAT is "default integer kind"  See 13.13 of the F95 standard.
This conforms to the standard.

   integer :: i = 1
   real x
   x = float(i)
   end

> The use of specific names is allowed in standard Fortran.
> It may be archaic and/or legacy, but definitely not non-standard !

This is nonstandard (assuming integer(8) is not the default integer kind)

   integer(8) :: i = 1_8
   real x
   x = float(i)
   end

The patch I committed allows float() to accept any integer kind.
I suppose I should add a warning if -std=f95 is used.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]