OpenMP directive turns a statement into a real code block
Peter Cech
pcech@vision.ee.ethz.ch
Sat Jun 20 12:10:00 GMT 2009
Hello,
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()
As I understand it, a structured block in OpenMP should not create a
real code block. Is this a bug/limitation of GGC's implementation or did
I miss something about OpenMP?
Thanks!
Peter Cech
More information about the Gcc-help
mailing list