This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH] New option to support asymmetric integer ranges in gfortran
Toon Moene wrote:
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".
A value of the form -2**(B-1) will likely only be used in bit operations
or as a flag of some sort; as such, the number represents a bit pattern,
and isn't actually a number used a context where it would be an argument
for ABS.
Therefore, it makes sense (to me) that -2**(B-1) be allowed as a value
for a B-bit integer, and that functions like ABS take appropriate action
when a given value exceeds their range. Instead of a
-fasymmetric-integers switch, we need to ensure that functions enforce
the model given in 13.7 and 13.14.
After all, I can define a real with the value -1.0, and SQRT is
responsible for rejecting it as invalid (in the domain of reals, of course.)
--
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing