https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102985
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Actually, I think 5.2 got this right and thus the testcase is not valid in 5.2. This is because of the introduction of work-distribution constructs term. For lastprivate the restriction now says: "A list item must not appear in a lastprivate clause on a work-distribution construct if the corresponding region binds to the region of a parallelism-generating construct in which the list item is private." This is violated in those testcases, the lastprivate original list item is private in teams there.