Peter Cech wrote: > I was adding some OpenMP paralellization into an existing code and run > into a puzzling problem. Here is a snippet to illustrate: > > // Inside a parallel for loop > > // The code statement below modifies a shared data structure > #pragma omp critical > Class instance = create_and_register_new_instance() > > // Problem here - compiler claims that "instance" was not declared in > // this scope > instance.do_something() > > So it seems that g++ 4.3 turns the code into: > > > // The code statement below modifies a shared data structure > #pragma omp critical > { > Class instance = create_and_register_new_instance() > } > > // "instance" not declared here > instance.do_something() > This looks right. If you wish the critical region to include more than a single statement, you need an explicit block with {}.