the simple omp-c++ testcase a.c caused g++ report error messages like
following:

# g++ -fopenmp a.c
a.c:14: error: 'a' declared 'threadprivate' after first use
# g++ -v
Using built-in specs.
Target: sparc-sun-solaris2.10
Configured with: /import/dr2/starlex/orig/trunk/configure
--prefix=/import/dr3/s10/gcc-4.3/ --enable-languages=c,c++,fortran
--disable-gnattools --with-mpfr=/ws/gccfss/tools --with-gmp=/ws/gccfss/tools
Thread model: posix
gcc version 4.3.0 20070912 (experimental) (GCC)

---------- src of a.c ----------
#include <stdio.h>
#include <omp.h>

class A {
  public:
    int i;
    A()
    {
        i = 10;
    };
};

A a;
#pragma omp threadprivate(a)

main()
{
    omp_set_dynamic(false);
    omp_set_num_threads(5);

    #pragma omp parallel
    {
        printf("a.i = %d\n", a.i);
    }
}
---------- end ----------


-- 
           Summary: declaration of threadprivate variable considered first
                    use
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hailijuan at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35246

Reply via email to