[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#658251: gfortran-4.6: Minimum integer cannot be parsed by read statement



Package: gfortran-4.6
Version: 4.6.2-12
Severity: normal

Dear Maintainer,

Formatted read statement cannot parse the minimum integer by a program
compiled by gfortran-4.6.

I compiled the following test program with no options,
----------------------------------------
  program test_int_min
    implicit none
    integer :: i
    integer :: ios
    read (*, *, IOSTAT=ios) i
    if (ios.ne.0) then
       write (*, *) 'ERROR', ios
    endif
    write (*, *) i, -i, -i-1, -i-2
    stop
  end program test_int_min
----------------------------------------

and executes as follows.

----------------------------------------
% gfortran test_int_min.f
% echo 2147483647  | ./a.out
  2147483647 -2147483647 -2147483648  2147483647
% echo -2147483647 | ./a.out
 -2147483647  2147483647  2147483646  2147483645
% echo -2147483648 | ./a.out
 ERROR        5010
           0           0          -1          -2
----------------------------------------

You see we can compute, store, write the actual minimum integer
-2147483648 in the program, but fail to read it.
Similar error occurs also when using a namelist.

I suspect that gfortran converts a string of a number to the absolute
value before sign treatment, which causes overflow of integer.

Best regards,

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-1-686-pae (SMP w/4 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gfortran-4.6 depends on:
ii  gcc-4.6       4.6.2-12
ii  gcc-4.6-base  4.6.2-12
ii  libc6         2.13-25
ii  libc6-dev     2.13-25
ii  libgfortran3  4.6.2-12
ii  libgmp10      2:5.0.3+dfsg-1
ii  libmpc2       0.9-4
ii  libmpfr4      3.1.0-3
ii  zlib1g        1:1.2.3.4.dfsg-3

gfortran-4.6 recommends no packages.

Versions of packages gfortran-4.6 suggests:
ii  gfortran-4.6-doc       <none>
ii  gfortran-4.6-multilib  4.6.2-12
ii  libgfortran3-dbg       4.6.2-12

-- no debconf information



Reply to: