https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123272
--- Comment #6 from Benjamin Schulz <schulz.benjamin at googlemail dot com> --- Interestingly, I can also recreate the problem purely on the host, if i write #pragma omp teams distribute parallel for collapse(2) instead of #pragma omp target teams distribute parallel for collapse(2) The host usually just has one team but the number of the teams seems not to matter for bringing the sum variable into the wrong scope. I then also get wrong numbers on a pure host computation. if i omit the teams distribute the sum is also being put between the loops, but why this does not lead to wrong numbers may be just a pure accident or that its not promoted to a shared variable... i tried various patches to /gcc/cp/semantics.cc, these did not cure the problem... I guess it may be a level higher, already at cp/parser.cc? I'll try that next...
