This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52053] New: SUM intrinsic is wrong for very large arrays
- From: "francois.willot at cmm dot ensmp.fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jan 2012 14:19:53 +0000
- Subject: [Bug fortran/52053] New: SUM intrinsic is wrong for very large arrays
- Auto-submitted: auto-generated
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.