[Bug c++/49418] openmp default(none) in template function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49418 --- Comment #1 from gcc-bug at safetymail dot info 2011-06-15 11:07:12 UTC --- Created attachment 24534 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24534 test case
[Bug c++/49418] openmp default(none) in template function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49418 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org --- Comment #2 from Jakub Jelinek 2011-06-21 13:32:06 UTC --- The problem seems to be that x has T const type before instantiation, but int (without const) after instantiation. The spot where the const is lost is: type = type_decays_to (type); TREE_TYPE (r) = type; cp_apply_type_quals_to_decl (cp_type_quals (type), r); Does C++ really mandate stripping the toplevel qualifiers from the PARM_DECLs here? It isn't stripped from VAR_DECLs. OpenMP 2.5/OpenMP 3.0 says that const qualified parameters and variables are predetermined shared. While it hopefully changes in some way in OpenMP 3.1 (though, the current 3.1 draft wording is likely to change, as it is backwards incompatible with default(none)), for older standards the presence/lack of const makes a big difference.
[Bug c++/49418] openmp default(none) in template function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49418 --- Comment #3 from Jakub Jelinek 2011-06-21 13:34:35 UTC --- Perhaps the top-level quals from the older type could be used, if the standard doesn't disallow it? Like, if T const arg is instantiated with T int or const int, it would be int const arg, while if it is T arg instantiated with int or const int, it would be int arg.
[Bug c++/49418] openmp default(none) in template function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49418 --- Comment #4 from Jakub Jelinek 2011-06-21 13:41:19 UTC --- template void f (int const x) { #pragma omp parallel default(none) int y = x; } template void g (int const x) { #pragma omp parallel default(none) shared(x) int y = x; } void h () { f (0); g (0); } fails the same way, while after removing template and the toplevel qualifier stays and it works as expected. If the current C++ FE behavior is mandated by the standard, i.e. toplevel qualifiers must be always dropped from function arguments when in templates and not otherwise, OpenMP C++ support could just ignore TREE_READONLY on PARM_DECLs in templates or something, but it looks very weird to me.
[Bug c++/49418] openmp default(none) in template function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49418 Jason Merrill changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2011.06.21 14:35:35 AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 --- Comment #5 from Jason Merrill 2011-06-21 14:35:35 UTC --- This is a bug, an unintended consequence of the change to type_decays_to.