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


Tobias Schlüter wrote:

Scott Robert Ladd wrote:

| different from a kind of 4. That way, the native integer(kind=4) could
| impose Fortran's integer model (which rejects -2147483648), while

Fortran doesn't impose an integer model. 13.7. only refers to the
functioning of the intrinsic subroutines. Any number that can be
represented by an integer kind is a valid value for this type. So
there's no need for the code in arith.c that you pointed to originally.

But there's another rule that applies in the discussed case. 13.14. reads:

"... A program is prohibited from invoking an intrinsic procedure under
circumstances where a value to be returned in a subroutine argument or
function result is outside the range of values representable by objects
of the specified type and type parameters."

In other words

I = -2147483647
I = I - 1
PRINT *, ABS(I)

is illegal, even thougfh all of it were allowed if 13.7. were read as a
restriction on the way integers should be dealt with by the compiler. Of
course detecting something like this in all cases is impossible.

So on the Fortran side ABS(-2147483647) is illegal ("the program is prohibited to ...") and on the C side the result is undefined (note: undefined, not "implementation defined").


That's pretty damning, I think. On both sides "you are not supposed to do this".

Of course, we can design a language Fortran 95+ where this is allowed and has a definite meaning, but we must be sure we really want this (people writing portable code will never want to use such a feature).

Hope this helps,

--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)


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