Integer read from stdin yields a value overflow for a valid integer.  Here's
the example program:

{{{
program int_range

integer*4 smallest

100 format(1i11)

read(5,100) smallest
print 100,smallest

end
}}}

If compiled and invoked as 

{{{
echo -2147483648 | ./int_range
}}}

it yields

{{{
Fortran runtime error: Value overflowed during integer read
}}}

but using -2147483647 works.  Shouldn't the most negative integer*4 be
-2^(31-1) = -2147483648 and the largest integer*4 be 2^(32-1)-1 = 2147483647? 
Just a note, the largest integer works with this code.


-- 
           Summary: Integer read from stdin yields a value overflow for a
                    valid integer.
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: szeliga at colorado dot edu
 GCC build triplet: powerpc-apple-darwin8
  GCC host triplet: powerpc-apple-darwin8
GCC target triplet: powerpc-apple-darwin8


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

Reply via email to