Bug 56217 - ICE: OpenMP: when combining shared() and a move constructor
Summary: ICE: OpenMP: when combining shared() and a move constructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2013-02-06 04:44 UTC by Jim Radford
Modified: 2013-02-19 17:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Radford 2013-02-06 04:44:01 UTC
// ICE with shared(std::unique_ptr<> or equiv) when using: -fopenmp -std=c++11 -O1

template <typename T>
struct ptr {
    T *p;
    ptr() : p() {}
    ptr(ptr &) = delete;
    ptr(ptr &&o) : p(o) {}
    operator T *() { return p; }
};

static ptr<int> f()
{
    ptr<int> pt;
    #pragma omp task shared(pt)
    pt.p = 0;
    return pt;
}

int main(int c, char **v)
{
    #pragma omp parallel
    #pragma omp single    
    f();
}
Comment 1 Richard Biener 2013-02-06 09:52:48 UTC
Confirmed.  On trunk we ICE with

t.C: In function 'ptr<int> f()':
t.C:15:15: error: invalid conversion in return statement
        return pt;
               ^
struct ptr

struct ptr &

return pt.5;

t.C:15:15: internal compiler error: verify_gimple failed
0xcfd441 verify_gimple_in_cfg(function*)
        /space/rguenther/src/svn/trunk/gcc/tree-cfg.c:4747
Comment 2 Jakub Jelinek 2013-02-06 10:35:02 UTC
Author: jakub
Date: Wed Feb  6 10:34:53 2013
New Revision: 195796

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195796
Log:
	PR middle-end/56217
	* omp-low.c (use_pointer_for_field): Return false if
	lower_send_shared_vars doesn't generate any copy-out code.

	* g++.dg/gomp/pr56217.C: New test.

	* testsuite/libgomp.c++/pr56217.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr56217.C
    trunk/libgomp/testsuite/libgomp.c++/pr56217.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgomp/ChangeLog
Comment 3 Jakub Jelinek 2013-02-06 10:43:34 UTC
Should be fixed on the trunk so far.  Note your testcase is invalid, without the taskwait I've added, it relies on NRV and even with NRV, by the time the task can run the temporary result of f() can be destructed already.
Comment 4 Jim Radford 2013-02-06 20:46:42 UTC
(In reply to comment #3)
> Should be fixed on the trunk

Thanks!

> Note your testcase is invalid, without
> the taskwait I've added, it relies on NRV and even with NRV, by the time the
> task can run the temporary result of f() can be destructed already.

I had the taskwait in my original.  Still, thanks for the explanation; it adds to my nascent mental model of openmp.  Maybe one day I'll get something to compile so I can try it out, but first I'm off to compile gcc!
Comment 5 Jakub Jelinek 2013-02-19 17:19:41 UTC
Author: jakub
Date: Tue Feb 19 17:19:36 2013
New Revision: 196141

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196141
Log:
	Backported from mainline
	2013-02-06  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56217
	* omp-low.c (use_pointer_for_field): Return false if
	lower_send_shared_vars doesn't generate any copy-out code.

	* g++.dg/gomp/pr56217.C: New test.

	* testsuite/libgomp.c++/pr56217.C: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/gomp/pr56217.C
    branches/gcc-4_7-branch/libgomp/testsuite/libgomp.c++/pr56217.C
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/omp-low.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/libgomp/ChangeLog
Comment 6 Jakub Jelinek 2013-02-19 17:38:02 UTC
Fixed for 4.7.3+.