http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51250
Bug #: 51250 Summary: [4.7 Regression] Bug with SUM(,dim,mask) Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: anl...@gmx.de The following program produces a wrong result: program gfcbug115 implicit none integer :: n_obstype = 2 integer :: nboxes = 1 integer :: nprocs = 1 integer :: nbox, j integer, allocatable :: nbx(:,:), pes(:) allocate (pes(nboxes)) allocate (nbx(n_obstype,nboxes)) nbx(:,:) = 1 do j = 1, nboxes pes(j) = modulo (j-1, nprocs) end do do nbox=1, nboxes print '(20i4)', nbox, nbx(:,nbox) end do do j = 0, nprocs-1 print '(i4,20l4)', j, spread (pes==j,dim=1,ncopies=n_obstype) print '(20i4)', j, & sum (nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype)), & shape (sum (nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype))) end do end program gfcbug115 gfortran 4.7 svn rev. 181390: 1 1 1 0 T T 0 1 1 gfortran 4.6 and earlier: 1 1 1 0 T T 0 1 1 2 The latter is correct.