public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30512]  New: MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1 maximum values.
@ 2007-01-20  0:10 brooks at gcc dot gnu dot org
  2007-01-20  9:38 ` [Bug fortran/30512] " burnus at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-01-20  0:10 UTC (permalink / raw)
  To: gcc-bugs

Consider the following program:

debian-gfortran:~/test> cat maxval.f90
integer(1) :: i(3)
logical :: msk(3)

i = -huge(i)
i = i - 1
write(*,*) i
write(*,*) maxval(i)

msk = .false.
i = 1
write(*,*) i
write(*,*) -huge(i), maxval(i, msk)
end

In both of these cases, the result of the MAXVAL call should be -huge(i)-1. 
(For the latter case, see the standard on the definition of the intrinsic,
which says that the result is the negative number with the largest magnitude
possible within the representation).  However, the actual result is this:

debian-gfortran:~/test> ../bin-trunk/bin/gfortran maxval.f90 -o maxval
debian-gfortran:~/test> ./maxval
 -128 -128 -128
 -127
    1    1    1
 -127 -127

This error holds for larger integer kinds, as well.

The error seems to stem from the libgfortran implementation, in which the
initial search value is initialized as -GFC_INTEGER_<n>_HUGE, where it should
be one less than that.


-- 
           Summary: MAXVAL() incorrect for zero-size int arrays, and for -
                    HUGE-1 maximum values.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brooks at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-02-20 17:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-20  0:10 [Bug fortran/30512] New: MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1 maximum values brooks at gcc dot gnu dot org
2007-01-20  9:38 ` [Bug fortran/30512] " burnus at gcc dot gnu dot org
2007-01-20 12:46 ` burnus at gcc dot gnu dot org
2007-01-22  7:56 ` fxcoudert at gcc dot gnu dot org
2007-01-22  8:47 ` burnus at gcc dot gnu dot org
2007-01-22 20:16 ` sgk at troutmask dot apl dot washington dot edu
2007-01-27 13:24 ` tkoenig at gcc dot gnu dot org
2007-01-28 22:39 ` tkoenig at gcc dot gnu dot org
2007-01-29  8:40 ` burnus at gcc dot gnu dot org
2007-01-30 17:58 ` burnus at gcc dot gnu dot org
2007-02-01  9:01 ` patchapp at dberlin dot org
2007-02-09 21:56 ` burnus at gcc dot gnu dot org
2007-02-16 14:16 ` [Bug fortran/30512] [4.2, 4.1 only] " burnus at gcc dot gnu dot org
2007-02-16 14:17 ` [Bug fortran/30512] [4.1 " burnus at gcc dot gnu dot org
2007-02-17 21:29 ` tkoenig at gcc dot gnu dot org
2007-02-20 17:39 ` burnus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).