OpenMP directive turns a statement into a real code block

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux