diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-04-05 09:31:28 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-04-05 09:31:28 +0200 |
commit | 592536eb3c0a97a55b1019ff0216ef77e6ca847e (patch) | |
tree | 73d684ddc1ac6db79cc19b77db7a603a16691804 /libgomp/testsuite | |
parent | 12b04452b40d49bb5322653cb5716b1ebf71b73d (diff) | |
download | gcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.zip gcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.tar.gz gcc-592536eb3c0a97a55b1019ff0216ef77e6ca847e.tar.bz2 |
c++: Fix ICE with weird copy assignment operator [PR114572]
While ctors/dtors don't return anything (undeclared void or this pointer
on arm) and copy assignment operators normally return a reference to *this,
it isn't invalid to return uselessly some class object which might need
destructing, but the OpenMP clause handling code wasn't expecting that.
The following patch fixes that.
2024-04-05 Jakub Jelinek <jakub@redhat.com>
PR c++/114572
* cp-gimplify.cc (cxx_omp_clause_apply_fn): Call build_cplus_new
on build_call_a result if it has class type.
* testsuite/libgomp.c++/pr114572.C: New test.
Diffstat (limited to 'libgomp/testsuite')
-rw-r--r-- | libgomp/testsuite/libgomp.c++/pr114572.C | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/pr114572.C b/libgomp/testsuite/libgomp.c++/pr114572.C new file mode 100644 index 0000000..21d5c84 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr114572.C @@ -0,0 +1,24 @@ +// PR c++/114572 +// { dg-do run } +// { dg-options "-fopenmp -O0" } + +#include <stdlib.h> + +struct S +{ + S () : s (0) {} + ~S () {} + S operator= (const S &x) { s = x.s; return *this; } + int s; +}; + +int +main () +{ + S s; + #pragma omp parallel for lastprivate(s) + for (int i = 0; i < 10; ++i) + s.s = i; + if (s.s != 9) + abort (); +} |