public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array
@ 2015-09-26 12:37 mikael at gcc dot gnu.org
  2015-09-26 12:40 ` [Bug fortran/67721] " mikael at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-09-26 12:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

            Bug ID: 67721
           Summary: deep copy missing when assigning a derived type
                    constructor to an array
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikael at gcc dot gnu.org
  Target Milestone: ---

In the following test, the assignment to v does a shallow copy of the rhs, so
that the c2 components are shared among array elements.
Then, any change made to one array element also impacts the other elements.

! { dg-do run }
!
! 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] 11+ messages in thread

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
@ 2015-09-26 12:40 ` mikael at gcc dot gnu.org
  2015-09-29 17:38 ` dominiq at lps dot ens.fr
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-09-26 12:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code
      Known to fail|                            |6.0

--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
Draft patch:

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


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
  2015-09-26 12:40 ` [Bug fortran/67721] " mikael at gcc dot gnu.org
  2015-09-29 17:38 ` dominiq at lps dot ens.fr
@ 2015-09-29 17:38 ` dominiq at lps dot ens.fr
  2015-10-01 13:31 ` mikael at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-29 17:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-09-29
     Ever confirmed|0                           |1


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
  2015-09-26 12:40 ` [Bug fortran/67721] " mikael at gcc dot gnu.org
@ 2015-09-29 17:38 ` dominiq at lps dot ens.fr
  2015-09-29 17:38 ` dominiq at lps dot ens.fr
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-29 17:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Any plan to back port the fix to 5.3? If no, the PR could be closed as FIXED.


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-09-29 17:38 ` dominiq at lps dot ens.fr
@ 2015-10-01 13:31 ` mikael at gcc dot gnu.org
  2015-10-01 14:02 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-01 13:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #3)
> Any plan to back port the fix to 5.3?

Yes, Paul suggested it in his approval message.
I'm doing it now.


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-10-01 13:31 ` mikael at gcc dot gnu.org
@ 2015-10-01 14:02 ` mikael at gcc dot gnu.org
  2015-10-01 14:04 ` mikael at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-01 14:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Thu Oct  1 14:01:37 2015
New Revision: 228339

URL: https://gcc.gnu.org/viewcvs?rev=228339&root=gcc&view=rev
Log:
Fix missing deep copy when assigning a DT constructor to an array

This adds the missing deep copy when assiging a constructor of a derived
type with allocatable components to an array.

The check for constantness is removed so that the deep_copy argument passed
to gfc_trans_scalar_assign is set to true.

        PR fortran/67721
gcc/fortran/
        * trans-expr.c (gfc_trans_assignment_1): Remove the non-constantness
        condition guarding deep copy.
gcc/testsuite/
        * gfortran.dg/alloc_comp_deep_copy_3.f03: New.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_3.f03
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/trans-expr.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-10-01 14:02 ` mikael at gcc dot gnu.org
@ 2015-10-01 14:04 ` mikael at gcc dot gnu.org
  2015-10-01 14:06 ` mikael at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-01 14:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

--- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Revision: 228170
Modified property: svn:log

Modified: svn:log at Thu Oct  1 14:03:32 2015
------------------------------------------------------------------------------
--- svn:log (original)
+++ svn:log Thu Oct  1 14:03:32 2015
@@ -3,7 +3,7 @@
 This adds the missing deep copy when assiging a constructor of a derived
 type with allocatable components to an array.

-The check for consantness is removed so that the deep_copy argument passed
+The check for constantness is removed so that the deep_copy argument passed
 to gfc_trans_scalar_assign is set to true.

        PR fortran/67721


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-10-01 14:04 ` mikael at gcc dot gnu.org
@ 2015-10-01 14:06 ` mikael at gcc dot gnu.org
  2015-10-02 15:05 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-01 14:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |mikael at gcc dot gnu.org

--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
Fixed for 5.3 and 6.0.
Closing


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2015-10-01 14:06 ` mikael at gcc dot gnu.org
@ 2015-10-02 15:05 ` hjl.tools at gmail dot com
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
  2015-10-19 11:33 ` mikael at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: hjl.tools at gmail dot com @ 2015-10-02 15:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

H.J. Lu <hjl.tools at gmail dot com> changed:

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

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
On Linux/x86-64, gfortran.dg/alloc_comp_deep_copy_3.f03 failed
on gcc-5-branch branch:

https://gcc.gnu.org/ml/gcc-regression/2015-10/msg00021.html

FAIL: libgomp.fortran/alloc-comp-2.f90   -O0  execution test
FAIL: libgomp.fortran/alloc-comp-2.f90   -O2  execution test
FAIL: libgomp.fortran/alloc-comp-3.f90   -O0  execution test
FAIL: libgomp.fortran/alloc-comp-3.f90   -O0  execution test
FAIL: libgomp.fortran/alloc-comp-3.f90   -O2  execution test
FAIL: libgomp.fortran/alloc-comp-3.f90   -O2  execution tes


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2015-10-02 15:05 ` hjl.tools at gmail dot com
@ 2015-10-18 15:01 ` mikael at gcc dot gnu.org
  2015-10-19 11:33 ` mikael at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-18 15:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

--- Comment #9 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Sun Oct 18 15:01:03 2015
New Revision: 228945

URL: https://gcc.gnu.org/viewcvs?rev=228945&root=gcc&view=rev
Log:
        PR fortran/67721
        PR fortran/67818
        Backport from mainline r222477:

        2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
gcc/fortran/
        * trans-array.c (duplicate_allocatable): Fixed deep copy of
        allocatable components, which are liable for copy only, when
        they are allocated.
        (gfc_duplicate_allocatable): Add deep-copy code into if
        component allocated block. Needed interface change for that.
        (gfc_copy_allocatable_data): Supplying NULL_TREE for code to
        add into if-block for checking whether a component was
        allocated.
        (gfc_duplicate_allocatable_nocopy): Likewise.
        (structure_alloc_comps): Likewise.
        * trans-array.h: Likewise.
        * trans-expr.c (gfc_trans_alloc_subarray_assign): Likewise.
        * trans-openmp.c (gfc_walk_alloc_comps): Likewise.
gcc/testsuite/
        * gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
        * gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_1.f03
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_2.f03
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/trans-array.c
    branches/gcc-5-branch/gcc/fortran/trans-array.h
    branches/gcc-5-branch/gcc/fortran/trans-expr.c
    branches/gcc-5-branch/gcc/fortran/trans-openmp.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/67721] deep copy missing when assigning a derived type constructor to an array
  2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
@ 2015-10-19 11:33 ` mikael at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-19 11:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67721

Mikael Morin <mikael at gcc dot gnu.org> changed:

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

--- Comment #10 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #8)
> On Linux/x86-64, gfortran.dg/alloc_comp_deep_copy_3.f03 failed
> on gcc-5-branch branch:

Fixed with r228945.
Closing again.


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

end of thread, other threads:[~2015-10-19 11:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-26 12:37 [Bug fortran/67721] New: deep copy missing when assigning a derived type constructor to an array mikael at gcc dot gnu.org
2015-09-26 12:40 ` [Bug fortran/67721] " mikael at gcc dot gnu.org
2015-09-29 17:38 ` dominiq at lps dot ens.fr
2015-09-29 17:38 ` dominiq at lps dot ens.fr
2015-10-01 13:31 ` mikael at gcc dot gnu.org
2015-10-01 14:02 ` mikael at gcc dot gnu.org
2015-10-01 14:04 ` mikael at gcc dot gnu.org
2015-10-01 14:06 ` mikael at gcc dot gnu.org
2015-10-02 15:05 ` hjl.tools at gmail dot com
2015-10-18 15:01 ` mikael at gcc dot gnu.org
2015-10-19 11:33 ` mikael 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).