This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] New option to support asymmetric integer ranges in gfortran
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Since my last mail doesn't seem to have made it through to the mailing
list, I'll insist on the same point once again. Sorry if you got my
previous mail.
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.
I think the compiler should behave the way the ones Joost pointed to
did: issue a warning for the huge negative literal, and, where possible,
issue an error (maybe conditionalized on -pedantic) in the case which is
covered by 13.14. I don't think it's a good idea to add
- -fasymmetric-integers. It's a cure for a problem which doesn't
exist/which only exists because of a misreading of 13.7 (the code in
arith.c), while not touching the real problem (the restriction imposed
by 13.14).
- - Tobi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1-nr1 (Windows 2000)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/7NXjRFv08TP0Y+sRAuSAAKCxi+FKnZ/HnuJCQcb+YScOo9g4KgCg2Bqx
UsSJxU8JDFXW2CocFUD6yJo=
=26id
-----END PGP SIGNATURE-----