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
On Fri, Dec 26, 2003 at 02:21:34PM -0500, Scott Robert Ladd wrote:
> Steve Kargl wrote:
> >What is the behavior the following program with your switch?
> >
> >program parambug
> > implicit none
> > integer, parameter :: MY_KIND = SELECTED_INT_KIND(9)
> > integer(MY_KIND), parameter :: X = -2147483648_MY_KIND
> > write (*,*) X,",",MY_KIND
> > write (*,*) ABS(X)
> >end program parambug
>
> Compiled with my flag, your program prints:
>
> -2147483648 , 4
> -2147483648
>
> Clearly, a wrong answer -- but it is the *same* wrong answer displayed
> by Intel and Lahey. And translating the code to C for compilation with
> gcc produces the same result.
Thanks for checking. This is what I wanted to see, but I
obviously forgot to ask.
> Being a non-conformist by nature, a voice in the back of my head says:
> "Damn compatibility!" But I know in my heart of hearts that gfortran's
> correctness is a potential problem in a world populated by
> less-than-perfect compilers and languages. So I think that a flag that
> enables "bad" behavior is appropriate, for situations where one must
> interact with others.
>
> I should bring this up on comp.lang.fortran to see what the general
> community thinks of all this.
I suspect you'll get the standard "You invoked an intrinsic function
with a number outside the model for integers, so you are getting
processor defined behavior (i.e., you just started WW III)."
--
Steve