* [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array
@ 2015-09-26 18:11 Mikael Morin
2015-09-26 18:21 ` Paul Richard Thomas
2015-10-02 16:33 ` H.J. Lu
0 siblings, 2 replies; 4+ messages in thread
From: Mikael Morin @ 2015-09-26 18:11 UTC (permalink / raw)
To: gcc-patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
Hello,
I've just submitted this PR, and the patch as well, which passes the
testsuite.
The problem is a missing deep copy when the rhs is a (scalar) derived
type constructor (with allocatable components) and the lhs an array.
The patch removes the nonconstantness condition, so that the deep_copy
flag passed to gfc_trans_scalar_assign is set to true.
Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
Mikael
[-- Attachment #2: pr67721_v1.CL --]
[-- Type: text/plain, Size: 283 bytes --]
2015-09-26 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/67721
* trans-expr.c (gfc_trans_assignment_1): Remove the non-constantness
condition guarding deep copy.
2015-09-26 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/67721
* gfortran.dg/alloc_comp_deep_copy_3.f03: New.
[-- Attachment #3: pr67721_v1.diff --]
[-- Type: text/x-patch, Size: 558 bytes --]
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index cfa1a71..e086fe3 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -9232,7 +9232,6 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
scalar_to_array = (expr2->ts.type == BT_DERIVED
&& expr2->ts.u.derived->attr.alloc_comp
&& !expr_is_variable (expr2)
- && !gfc_is_constant_expr (expr2)
&& expr1->rank && !expr2->rank);
scalar_to_array |= (expr1->ts.type == BT_DERIVED
&& expr1->rank
[-- Attachment #4: alloc_comp_deep_copy_3.f03 --]
[-- Type: text/plain, Size: 583 bytes --]
! { dg-do run }
!
! PR fortran/67721
! Check that scalar to array assignments of derived type constructor
! deep copy the value when there are allocatable components.
program p
implicit none
type :: t1
integer :: c1
end type t1
type :: t2
type(t1), allocatable :: c2
end type t2
block
type(t2) :: v(4)
v = t2(t1(3))
v(2)%c2%c1 = 7
v(3)%c2%c1 = 11
v(4)%c2%c1 = 13
if (v(1)%c2%c1 /= 3) call abort
if (v(2)%c2%c1 /= 7) call abort
if (v(3)%c2%c1 /= 11) call abort
if (v(4)%c2%c1 /= 13) call abort
end block
end program p
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array
2015-09-26 18:11 [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array Mikael Morin
@ 2015-09-26 18:21 ` Paul Richard Thomas
2015-10-02 16:33 ` H.J. Lu
1 sibling, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2015-09-26 18:21 UTC (permalink / raw)
To: Mikael Morin; +Cc: gcc-patches, gfortran
Dear Mikael,
Apart from the regtesting, this patch is 'obvious'. This is good for
trunk and, I would suggest, after a decent interval 5 branch.
Thanks for the PR and the patch.
Paul
On 26 September 2015 at 15:10, Mikael Morin <mikael.morin@sfr.fr> wrote:
> Hello,
>
> I've just submitted this PR, and the patch as well, which passes the
> testsuite.
>
> The problem is a missing deep copy when the rhs is a (scalar) derived type
> constructor (with allocatable components) and the lhs an array.
> The patch removes the nonconstantness condition, so that the deep_copy flag
> passed to gfc_trans_scalar_assign is set to true.
>
> Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
> Mikael
>
--
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.
Groucho Marx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array
2015-09-26 18:11 [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array Mikael Morin
2015-09-26 18:21 ` Paul Richard Thomas
@ 2015-10-02 16:33 ` H.J. Lu
2015-10-02 16:35 ` Steve Kargl
1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2015-10-02 16:33 UTC (permalink / raw)
To: Mikael Morin; +Cc: gcc-patches, gfortran
On Sat, Sep 26, 2015 at 6:10 AM, Mikael Morin <mikael.morin@sfr.fr> wrote:
> Hello,
>
> I've just submitted this PR, and the patch as well, which passes the
> testsuite.
>
> The problem is a missing deep copy when the rhs is a (scalar) derived type
> constructor (with allocatable components) and the lhs an array.
> The patch removes the nonconstantness condition, so that the deep_copy flag
> passed to gfc_trans_scalar_assign is set to true.
>
> Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
> Mikael
>
This caused:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67818
on GCC 5 branch.
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array
2015-10-02 16:33 ` H.J. Lu
@ 2015-10-02 16:35 ` Steve Kargl
0 siblings, 0 replies; 4+ messages in thread
From: Steve Kargl @ 2015-10-02 16:35 UTC (permalink / raw)
To: H.J. Lu; +Cc: Mikael Morin, gcc-patches, gfortran
On Fri, Oct 02, 2015 at 09:33:33AM -0700, H.J. Lu wrote:
> On Sat, Sep 26, 2015 at 6:10 AM, Mikael Morin <mikael.morin@sfr.fr> wrote:
> > Hello,
> >
> > I've just submitted this PR, and the patch as well, which passes the
> > testsuite.
> >
> > The problem is a missing deep copy when the rhs is a (scalar) derived type
> > constructor (with allocatable components) and the lhs an array.
> > The patch removes the nonconstantness condition, so that the deep_copy flag
> > passed to gfc_trans_scalar_assign is set to true.
> >
> > Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
> > Mikael
> >
>
> This caused:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67818
>
> on GCC 5 branch.
>
Fairly, uninformative bug report.
--
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-02 16:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-26 18:11 [Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array Mikael Morin
2015-09-26 18:21 ` Paul Richard Thomas
2015-10-02 16:33 ` H.J. Lu
2015-10-02 16:35 ` Steve Kargl
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).