[flang] [openmp] Flang with OMP 5.1 accepts Capture and Expected variables to be the same in an atomic compare capture
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Release builds of Flang with OMP 5.1 currently compile the following without error:
```fortran
subroutine pre_cap_02(var1, num1, num2, num3)
integer :: var1, num1, num2, num3
!$omp atomic compare capture
num1 = num1
if (var1 == num1) then
var1 = num2
end if
!$omp end atomic
end subroutine
```
Capture and Expected variables cannot be the same in an OpenMP atomic compare capture region.
Debug builds of Flang with OMP 5.1 with the same code, fail to compile with a failed assert in `OmpStructureChecker::CheckAtomicCaptureAssignment` within `flang/lib/Semantics/check-omp-atomic.cpp` at lines 841-843. That assert was recently changed, so I suspect this is a simple oversight.
Contributor guide
Research direction
Start in flang/lib/Semantics/check-omp-atomic.cpp at OmpStructureChecker::CheckAtomicCaptureAssignment, especially the logic around lines 841-843. Reproduce the supplied atomic compare capture example in release and debug builds. Done means the invalid shared Capture and Expected variables are rejected consistently without a failed assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fortran
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100