public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49418] New: openmp default(none) in template function
@ 2011-06-15 11:06 gcc-bug at safetymail dot info
  2011-06-15 11:07 ` [Bug c++/49418] " gcc-bug at safetymail dot info
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: gcc-bug at safetymail dot info @ 2011-06-15 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: openmp default(none) in template function
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gcc-bug@safetymail.info


Compilation fails, if within a template function a const argument is used
within an openmp parallel region with default(none).

If shared(x) is specified also a "predetermined 'shared'" error is produced.


Error:
$ g++ -fopenmp pf.cc
pf.cc: In function 'void g(T)':
pf.cc:11:45: error: 'x' is predetermined 'shared' for 'shared'
pf.cc: In function 'void f(T) [with T = int]':
pf.cc:5:8: error: 'x' not specified in enclosing parallel
pf.cc:5:8: error: enclosing parallel
pf.cc: In function 'void g(T) [with T = int]':
pf.cc:12:8: error: 'x' not specified in enclosing parallel
pf.cc:12:8: error: enclosing parallel

Version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/me/gcc/libexec/gcc/i686-pc-cygwin/4.6.0/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: ./configure --enable-languages=c,c++ --prefix=/home/me/gcc
--enable-libgomp
Thread model: single
gcc version 4.6.0 (GCC)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] openmp default(none) in template function
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
@ 2011-06-15 11:07 ` gcc-bug at safetymail dot info
  2011-06-21 13:33 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gcc-bug at safetymail dot info @ 2011-06-15 11:07 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] openmp default(none) in template function
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
  2011-06-15 11:07 ` [Bug c++/49418] " gcc-bug at safetymail dot info
@ 2011-06-21 13:33 ` jakub at gcc dot gnu.org
  2011-06-21 13:35 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-21 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] openmp default(none) in template function
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
  2011-06-15 11:07 ` [Bug c++/49418] " gcc-bug at safetymail dot info
  2011-06-21 13:33 ` jakub at gcc dot gnu.org
@ 2011-06-21 13:35 ` jakub at gcc dot gnu.org
  2011-06-21 13:42 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-21 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] openmp default(none) in template function
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (2 preceding siblings ...)
  2011-06-21 13:35 ` jakub at gcc dot gnu.org
@ 2011-06-21 13:42 ` jakub at gcc dot gnu.org
  2011-06-21 14:35 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-21 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-21 13:41:19 UTC ---
template <typename T>
void f (int const x)
{
#pragma omp parallel default(none)
  int y = x;
}

template <typename T>
void g (int const x)
{
#pragma omp parallel default(none) shared(x)
  int y = x;
}

void h ()
{
  f<int> (0);
  g<int> (0);
}

fails the same way, while after removing template <typename T> and <int>
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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] openmp default(none) in template function
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (3 preceding siblings ...)
  2011-06-21 13:42 ` jakub at gcc dot gnu.org
@ 2011-06-21 14:35 ` jason at gcc dot gnu.org
  2011-06-21 18:59 ` [Bug c++/49418] [4.6/4.7 regression] G++ discards cv-quals from template parameter types jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-21 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> 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 <jason at gcc dot gnu.org> 2011-06-21 14:35:35 UTC ---
This is a bug, an unintended consequence of the change to type_decays_to.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6/4.7 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (4 preceding siblings ...)
  2011-06-21 14:35 ` jason at gcc dot gnu.org
@ 2011-06-21 18:59 ` jason at gcc dot gnu.org
  2011-06-21 19:05 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-21 18:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.6.2
            Summary|openmp default(none) in     |[4.6/4.7 regression] G++
                   |template function           |discards cv-quals from
                   |                            |template parameter types

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-21 18:58:53 UTC ---
Changing the summary to reflect the underlying issue.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6/4.7 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (5 preceding siblings ...)
  2011-06-21 18:59 ` [Bug c++/49418] [4.6/4.7 regression] G++ discards cv-quals from template parameter types jason at gcc dot gnu.org
@ 2011-06-21 19:05 ` jason at gcc dot gnu.org
  2011-06-21 19:08 ` [Bug c++/49418] [4.6 " jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-21 19:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-21 19:05:28 UTC ---
Author: jason
Date: Tue Jun 21 19:05:25 2011
New Revision: 175271

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175271
Log:
    PR c++/49418
    * call.c (cxx_type_promotes_to): Don't strip cv-quals.
    * semantics.c (lambda_return_type): Strip them here.

Added:
    trunk/gcc/testsuite/g++.dg/template/param3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (6 preceding siblings ...)
  2011-06-21 19:05 ` jason at gcc dot gnu.org
@ 2011-06-21 19:08 ` jason at gcc dot gnu.org
  2011-06-24  2:19 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-21 19:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.6/4.7 regression] G++    |[4.6 regression] G++
                   |discards cv-quals from      |discards cv-quals from
                   |template parameter types    |template parameter types

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-21 19:07:21 UTC ---
Fixed on trunk.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (7 preceding siblings ...)
  2011-06-21 19:08 ` [Bug c++/49418] [4.6 " jason at gcc dot gnu.org
@ 2011-06-24  2:19 ` jason at gcc dot gnu.org
  2011-06-27 20:16 ` jason at gcc dot gnu.org
  2011-06-27 20:18 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-24  2:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-24 02:18:46 UTC ---
Author: jason
Date: Fri Jun 24 02:18:42 2011
New Revision: 175368

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175368
Log:
    PR c++/49418
    * typeck2.c (build_functional_cast): Strip cv-quals for value init.
    * init.c (build_zero_init_1): Not here.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/cp/typeck2.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (8 preceding siblings ...)
  2011-06-24  2:19 ` jason at gcc dot gnu.org
@ 2011-06-27 20:16 ` jason at gcc dot gnu.org
  2011-06-27 20:18 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-27 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-27 20:15:56 UTC ---
Author: jason
Date: Mon Jun 27 20:15:49 2011
New Revision: 175557

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175557
Log:
    PR c++/49418
    * call.c (cxx_type_promotes_to): Don't strip cv-quals.
    * semantics.c (lambda_return_type): Strip them here.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/template/param3.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/call.c
    branches/gcc-4_6-branch/gcc/cp/semantics.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/49418] [4.6 regression] G++ discards cv-quals from template parameter types
  2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
                   ` (9 preceding siblings ...)
  2011-06-27 20:16 ` jason at gcc dot gnu.org
@ 2011-06-27 20:18 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-27 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-27 20:18:04 UTC ---
Fixed for 4.6.2.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-06-27 20:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-15 11:06 [Bug c++/49418] New: openmp default(none) in template function gcc-bug at safetymail dot info
2011-06-15 11:07 ` [Bug c++/49418] " gcc-bug at safetymail dot info
2011-06-21 13:33 ` jakub at gcc dot gnu.org
2011-06-21 13:35 ` jakub at gcc dot gnu.org
2011-06-21 13:42 ` jakub at gcc dot gnu.org
2011-06-21 14:35 ` jason at gcc dot gnu.org
2011-06-21 18:59 ` [Bug c++/49418] [4.6/4.7 regression] G++ discards cv-quals from template parameter types jason at gcc dot gnu.org
2011-06-21 19:05 ` jason at gcc dot gnu.org
2011-06-21 19:08 ` [Bug c++/49418] [4.6 " jason at gcc dot gnu.org
2011-06-24  2:19 ` jason at gcc dot gnu.org
2011-06-27 20:16 ` jason at gcc dot gnu.org
2011-06-27 20:18 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).