https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87668
Bug ID: 87668 Summary: [OpenMP] Complains about loop bound variable not being shared, even though unused in the loop Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lebedev.ri at gmail dot com Target Milestone: --- https://godbolt.org/z/05Zgdd #include <vector> struct b {}; void c() { std::vector<b> d; #ifdef _OPENMP #pragma omp parallel default(none) #pragma omp for #endif for (auto f = d.begin(); f < d.end(); ++f) ; } #ifndef _OPENMP Yes, there is OMP. #endif GCC output: <source>: In function 'void c()': <source>:9:25: error: 'd' not specified in enclosing 'parallel' for (auto f = d.begin(); f < d.end(); ++f) ^ <source>:6:9: error: enclosing 'parallel' #pragma omp parallel default(none) ^~~ Compiler returned: 1 Clang is perfectly happy with that code. Since the 'd' isn't actually used in the parallel loop body, but only in the loop bound checking, shouldn't gcc not complain about this, too?