https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117247
Bug ID: 117247 Summary: [OpenMP][nvptx] cuCtxSynchronize with 'omp target loop' + PRIVATE clause and -O1 (OpenMP_VV's teams_loop/test_target_teams_loop_private.c) Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openmp, wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: tschwinge at gcc dot gnu.org Target Milestone: --- Created attachment 59402 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59402&action=edit C testcase Shows up with OpenMP_VV's https://github.com/OpenMP-Validation-and-Verification/OpenMP_VV/blob/master/tests/5.0/teams_loop/test_target_teams_loop_private.c It works with AMD GCN or -O0 but with -O1 and higher, it fails with: libgomp: cuCtxSynchronize error: an illegal memory access was encountered libgomp: cuMemFree_v2 error: an illegal memory access was encountered libgomp: device finalization failed The problem is 'omp target' + 'omp loop' + 'private'; using 'for' instead of 'loop' works. Simplified test case attached ('target loop' not 'target teams loop').