This is the mail archive of the
`gcc-patches@gcc.gnu.org`
mailing list for the GCC 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] |

*From*: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>*To*: Scott Robert Ladd <coyote at coyotegulch dot com>*Cc*: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org*Date*: Fri, 26 Dec 2003 10:58:38 -0800*Subject*: Re: [PATCH] New option to support asymmetric integer ranges in gfortran*References*: <3FEC80D9.4010203@coyotegulch.com>

On Fri, Dec 26, 2003 at 01:41:29PM -0500, Scott Robert Ladd wrote: > > Section 13.7.1 of ISO/IEC 1539-1 ("Fortran 95") specifies that integers > be symmetrical around zero. For example, in terms of an 8-bit integer, > Fortran 95 requires integer values to be in the range [-127,+127]. Two's > complement representation, used on the majority of GCC-supported > platforms, supports the asymmetrical range [-128,+127]. > > Other programming languages and Fortran 95 compilers support the minimum > allowed by two's complement representation; this could result in > incompatibility between gfortran-generated code and values produced by > other languages or compilers. > > The following patch allows gfortran to ignore the limits of 13.7.1 for > the purpose of accepting two's complement minimum values. > > Tested on ia32 (P3 and P4); my ancient ultrasparc is still compiling the > compiler. > > Example: > > The following program only compiles and runs with use of the > -fasymmetric-integers flag (implemented by this patch): > > program parambug > implicit none > integer, parameter :: MY_KIND = SELECTED_INT_KIND(9) > integer(MY_KIND), parameter :: X = -2147483648_MY_KIND > write (*,*) X,",",MY_KIND > end program parambug > > When compiled with gfortran and -fasymmetric-integers, the program > produces the output: > > -2147483648 , 4 > > The above result matches the output of the program when it is compiled > with Lahey Fortran 95 6.1 and Intel Fortran 95 8.0. > What is the behavior the following program with your switch? program parambug implicit none integer, parameter :: MY_KIND = SELECTED_INT_KIND(9) integer(MY_KIND), parameter :: X = -2147483648_MY_KIND write (*,*) X,",",MY_KIND write (*,*) ABS(X) end program parambug The F2003 draft states: ABS(A) Description. Absolute value. Class. Elemental function. Argument. A shall be of type integer, real, or complex. Result Characteristics. The same as A except that if A is complex, the result is real. Result Value. If A is of type integer or real, the value of the result is |A|; if A is complex with value (x,y), the result is equal to a processor-dependent approximation to sqrt(x**2+y**2). -- Steve

**Follow-Ups**:**Re: [PATCH] New option to support asymmetric integer ranges in gfortran***From:*Scott Robert Ladd

**References**:**[PATCH] New option to support asymmetric integer ranges in gfortran***From:*Scott Robert Ladd

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |