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



kargl at gcc dot gnu.org changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |kargl at gcc dot gnu.org



--- Comment #1 from kargl at gcc dot gnu.org 2012-10-15 15:40:28 UTC ---

Jan,



It's a convoluted problem.  In gfortran, to get

the maximum range of an integer type you need

to use [-huge(i)-1:huge(i)] where 'i' is of the

type of interest.  This is a result of gfortran

seeing a number like -4294967297 as a unary minus

with an operand of 4294967297.  4294967297 without

a kind suffix is of default integer kind, which is

a 32-bit signed int, and 4294967297 is slightly 

larger than huge(1) = 2147483647.  Note, Fortran

does not have unsigned integers.  If you don't

want to or cannot use the -fno-range-check option,

you can do 



        integer(8), parameter :: n = 2 * (huge(1_4) + 1_8) + 1

        dimension foo(n-1:n)

        dimension bar(-n-1:-n)

        bar = 42

        foo = bar

        print *, n

        stop

        end



where I correctly initialize bar to some value; otherwise, the

code is invalid Fortran.  You could also decorate the integers

with a integer kind suffix



        dimension foo(4294967296_8:4294967297_8)

        dimension bar(-4294967297_8:-4294967296_8)

        bar = 42

        foo=bar

        stop

        end



Here, the _8 tells gfortran to use a signed 64-bit int.



Both code snippets above compile on my x86_64-*-freebsd.

I don't know want happens on an i686 target.

Reply via email to