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: [PATCH] New option to support asymmetric integer ranges in gfortran


Steve Kargl wrote:
I can't check the ISO C standard, but I think appealing to the
interoperability of Fortran and C is not a very good argument.

From 7.20.6.1 of ISO/IEC 9899:1999 ("Standard C"):


The abs, labs, and llabs functions compute the absolute value of an integer j. If the result cannot be represented, the behavior is undefined. 256)

Footnote:
256) The absolute value of the most negative number cannot be represented in two's complement.


In other words, we're consistent in that the absolute value of the most negative integer is undefined in the standards. As such, my proposed patch allows gfortran to behave in conformance with standard practice.

As for interoperability: It is one of the foci in the proposed Fortran "2003" Standard. The ISO_C_BINDING intrinsic module defines kinds that will to operate across the Fortran/C boundary... C_INT32_T, for example.

Perhaps, for Fortran 2003, we would define a kind of C_INT32_T as different from a kind of 4. That way, the native integer(kind=4) could impose Fortran's integer model (which rejects -2147483648), while integer(kind=C_INT32_T) allows -2147483648. In fact, this may be the very intent of the new standard.

Just a thought.

--
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing



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