This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/30834] ICE with kind=8 exponentiaton



------- Comment #6 from sgk at troutmask dot apl dot washington dot edu  2007-02-17 21:51 -------
Subject: Re:  ICE with kind=8 exponentiaton

On Sat, Feb 17, 2007 at 09:27:07PM -0000, tkoenig at gcc dot gnu dot org wrote:
> 
> > After looking at this a little bit, I think we may want to
> > change the error message to report the invalid integer exponent 
> > value and document that INT_MIN <= e <= INT_MAX.  Why?  Well, 
> > other than the special values of 1 and 0, the evaluation of
> > x**e will exceed the range of x.
> 
> I don't think this is the case:
> 
> $ cat foo.f90
> program main
>   real(kind=8) :: a
>   integer(kind=8) :: n
>   n = 2_8**32
>   a = 1_8 + epsilon(a)
>   print *,a**n
> end program main
> $ gfortran foo.f90
> $ ./a.out
>    1.00000095367477
> 
> I do admit this is a corner case, though :-)
> 

OK, for numbers outside the nominal range of
x  in (1_8 - 1.651e-7_8, 1_8 + 1.651e-7_8), then x**e and e = INT_MAX
you have problems.  There is also a range (-f,f) with f << 1 where
e could exceed the range [INT_MIN, INT_MAX].  I'm too lazy to determin
f.  Feel free to create a gfc_extract_long_long and document that
e is constrained to be within [LONG_LONG_MIN, LONG_LONG_MAX].


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30834


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