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: Minimum integer values


Tobias Schlüter wrote:
Scott Robert Ladd wrote:
|
| Looking at arith.c, I find this comment:
|
|       mpz_init (int_info->min_int);
|       mpz_neg (int_info->min_int, int_info->huge);
|       /* No -1 here, because the representation is symmetric.  */
|
|
| Yet I can't find anything in the Fortran 95 standard that supports the
| contention that potitive and negative values are symmetric (as suggested
| by the comment.
|
| So is this a bug or not? It certainly is different from other Fortran 95
| compilers...

See section 13.7.1. This is a fairly strict interpretation of the
standard if I recall all the details correctly.

From a platform-independence standpoint, 13.7.1 makes sense; however, it does pose some definite problems in regard to interoperability between languages.


In my code, I use an "all bits set" mask in a bitwise calculation; under the strict interpretation of 13.7.1, this is not possible with Fortran on a two's complement system, since 0xFFFFFFFF lies outside the defined boundaries of a 32-bit Fortran integer.

In addition, other languages (and the processor itself) accept -2,147,483,648 is a valid value for a 32-bit signed integer on a two's complement platform. This incompatibility could lead to problems with code compiled by other Fortran compilers, or with values supplied directly or indirectly from code compiled from other programming languages.

Given that other compilers accept this silently, I think there should at least be a switch to control strict adherence to 13.7.1 (or section 13.4 in the Oct 2003 final committee draft of the new standard).

--
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]