[Bug fortran/52053] New: SUM intrinsic is wrong for very large arrays
francois.willot at cmm dot ensmp.fr
gcc-bugzilla@gcc.gnu.org
Mon Jan 30 14:36:00 GMT 2012
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.
More information about the Gcc-bugs
mailing list