From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22591 invoked by alias); 20 Jan 2007 00:10:07 -0000 Received: (qmail 22449 invoked by uid 48); 20 Jan 2007 00:09:53 -0000 Date: Sat, 20 Jan 2007 00:10:00 -0000 Subject: [Bug fortran/30512] New: MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1 maximum values. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "brooks at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-01/txt/msg01563.txt.bz2 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__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