Bug 677637 - OpenMP C++ Code refuses to compile due to const modifier
Summary: OpenMP C++ Code refuses to compile due to const modifier
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-15 12:29 UTC by Peter Klotz
Modified: 2011-05-13 12:22 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-15 13:01:50 UTC
Target Upstream Version:


Attachments (Terms of Use)
Code that shows the problem (548 bytes, text/plain)
2011-02-15 12:29 UTC, Peter Klotz
no flags Details

Description Peter Klotz 2011-02-15 12:29:17 UTC
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:

Comment 2 Jakub Jelinek 2011-02-15 13:01:50 UTC
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.

Comment 3 Peter Klotz 2011-02-15 16:04:30 UTC
Thanks a lot for this detailed explanation.

Regards, Peter.


Note You need to log in before you can comment on or make changes to this bug.