http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52075
Bug #: 52075 Summary: OpenMP atomic update failing if -fbounds-check specified Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: lo...@cray.com Test code: ! derived from OpenMP test OMP3f/F03_2_8_5_3.F90 program F03_2_8_5_3 ! thread-num n sets bit 2**n in each element of the array (assuming 2**n can ! be represented by the data type). Each element of the array should contain ! 2**num-threads - 1. use omp_lib implicit none integer, parameter :: NT = 4 integer, parameter :: ARRAY_SIZE = 1024 integer :: X(ARRAY_SIZE) = 0, v, i call omp_set_dynamic(.false.); call omp_set_num_threads(NT); !$omp parallel private(v) if (omp_get_thread_num() < STORAGE_SIZE(X)) then do i = 1, ARRAY_SIZE !$omp atomic X(i) = IOR(X(i), 2**omp_get_thread_num()) end do end if !$omp end parallel do i = 1, ARRAY_SIZE if (X(i) /= MASKR(MIN(NT, STORAGE_SIZE(X)))) then write (*,*) 'FAIL - X(', i, ') == ', X(i), ' (expected ', & MASKR(MIN(NT, STORAGE_SIZE(X))),')' stop 1 end if end do end program F03_2_8_5_3 Works as expected with just -fopenmp: > ftn -fopenmp test.f90 > aprun -n1 -d4 ./a.out Application 6244707 resources: utime ~0s, stime ~0s > Failing (wrong answer) if -fbounds-check is also specified: > ftn -fopenmp -fbounds-check test.f90 > aprun -n1 -d4 ./a.out FAIL - X( 1 ) == 7 (expected 15 ) STOP 1 Application 6244710 exit codes: 1 Application 6244710 resources: utime ~0s, stime ~0s