Hide Forgot
Created attachment 478870 [details] Code that shows the problem Description of problem: The attached code results in the following compiler error: main.cpp: In function ‘int main(int, char**)’: main.cpp:22: error: ‘values’ is predetermined ‘shared’ for ‘shared’ Version-Release number of selected component (if applicable): gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) How reproducible: Compile the attached program using this command: g++ -c -o main.o -fopenmp -pipe -Wall -Wextra main.cpp Actual results: The above compiler error. Expected results: The code should compile. It compiles, if the "const" in line 17 is removed. It also compiles using gcc 4.1 under RHEL5. Additional info:
See OpenMP 3.0 standard, section 2.9.1.1, line 19 on page 78: "Variables with const-qualified type having no mutable member are shared." and lines 1-7 on page 79: "Variables with predetermined data-sharing attributes may not be listed in data-sharing attribute clauses, except for the cases listed below. For these exceptions only, listing a predetermined variable in a data-sharing attribute clause is allowed and overrides the variable’s predetermined data-sharing attributes. C/C++ The loop iteration variable(s) in the associated for-loop(s) of a for or parallel for construct may be listed in a private or lastprivate clause. Therefore your testcase is not valid OpenMP program and it is correct that GCC rejects it. Just remove the const var from shared clause.
Thanks a lot for this detailed explanation. Regards, Peter.