This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/52053] New: SUM intrinsic is wrong for very large arrays


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

             Bug #: 52053
           Summary: SUM intrinsic is wrong for very large arrays
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: francois.willot@cmm.ensmp.fr


I suspect this will not be considered a bug, but I'm not sure so just in case
I'll send this anyway:

$ cat test.f90
PROGRAM MAIN
IMPLICIT NONE
REAL(KIND=4) :: a(20,1000,1000)
a=1.0_8
PRINT *,SUM(a)
PRINT *,SUM(SUM(a,1))
END

$  gfortran test.f90 && ./a.out
   16777216.    
   20000000.    

$ gfortran --version
GNU Fortran (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

If an array contains values of the same order and you sum up all elements of it
with a loop, at some point the numbers you add become negligable compared to
the sum of the previous elements; whereas if you sum parts of the array
independantly and sum the results, you have a better chance of getting a
correct value.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]