[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-10-18 Thread mikael at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #21 from Mikael Morin  ---
Author: mikael
Date: Sun Oct 18 15:01:03 2015
New Revision: 228945

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

2015-04-27  Andre Vehreschild  

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


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-05-06 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #20 from vehre at gcc dot gnu.org ---
This patch is for trunk, aka 6.0.


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-05-05 Thread talebi.hossein at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #19 from Hossein Talebi talebi.hossein at gmail dot com ---
Hi,

This patch goes to Gfortran 4.8 or the current version? Thank you.

Cheers
H.

On Tue, May 5, 2015 at 7:03 PM, vehre at gcc dot gnu.org 
gcc-bugzi...@gcc.gnu.org wrote:

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

 vehre at gcc dot gnu.org changed:

What|Removed |Added

 
  Status|WAITING |RESOLVED
  Resolution|--- |FIXED

 --- Comment #18 from vehre at gcc dot gnu.org ---
 Resolved with commit r222477. No objections so far, closing.

 --
 You are receiving this mail because:
 You are on the CC list for the bug.
 You reported the bug.



[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-05-05 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

vehre at gcc dot gnu.org changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |FIXED

--- Comment #18 from vehre at gcc dot gnu.org ---
Resolved with commit r222477. No objections so far, closing.


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-04-27 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #17 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Mon Apr 27 17:34:11 2015
New Revision: 222477

URL: https://gcc.gnu.org/viewcvs?rev=222477root=gccview=rev
Log:
gcc/fortran
2015-04-27  Andre Vehreschild  ve...@gmx.de

PR fortran/59678
PR fortran/65841
* 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
2015-04-27  Andre Vehreschild  ve...@gmx.de

PR fortran/59678
PR fortran/65841
* gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
* gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


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


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2015-04-18 Thread vehre at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

vehre at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |WAITING

--- Comment #16 from vehre at gcc dot gnu.org ---
A patch is available at:

https://gcc.gnu.org/ml/fortran/2015-04/msg00061.html

awaiting review.


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2014-04-20 Thread talebi.hossein at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #15 from Hossein Talebi talebi.hossein at gmail dot com ---
Hi, will this bug be fixed anytime soon or is it fixed already in GCC4.9?


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2014-01-12 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|WAITING |NEW
Summary|Segmentation fault on   |[F03] Segfault on
   |equalizing variables of a   |equalizing variables of a
   |complex derived data type   |complex derived type

--- Comment #11 from janus at gcc dot gnu.org ---
Confirmed. Slightly reduced test case (fails at least with 4.6 up to trunk):

program hello
   implicit none

   type t3
  integer b
  integer, allocatable :: vec(:)
   end type

   type t2
  type(t3), allocatable :: obj
   end type

   type t1
  type(t2) :: parts
  integer :: a=1
   end type

   type(t1):: x, y

   y=x
end


The dump shows that the assignment is translated into:

  {
void * restrict D.2321;
integer(kind=8) D.2320;
integer(kind=8) D.2319;
integer(kind=8) D.2318;
struct t1 D.2317;

D.2317 = y;
y = x;
y.parts = x.parts;
y.parts.obj = x.parts.obj;
if ((void *) x.parts.obj.vec.data != 0B)
  {
D.2318 = (x.parts.obj.vec.dim[0].ubound -
x.parts.obj.vec.dim[0].lbound) + 1;
D.2319 = NON_LVALUE_EXPR D.2318;
D.2320 = D.2319 * 4;
D.2321 = (void * restrict) __builtin_malloc (MAX_EXPR (unsigned long)
D.2320, 1);
y.parts.obj.vec.data = D.2321;
__builtin_memcpy ((integer(kind=4)[0:] * restrict)
y.parts.obj.vec.data, (integer(kind=4)[0:] * restrict) x.parts.obj.vec.data,
(unsigned long) (D.2319 * 4));
  }
else
  {
y.parts.obj.vec.data = 0B;
  }
if (D.2317.parts.obj != 0B)
  {
if (D.2317.parts.obj-vec.data != 0B)
  {
__builtin_free ((void *) D.2317.parts.obj-vec.data);
  }
D.2317.parts.obj-vec.data = 0B;
__builtin_free ((void *) D.2317.parts.obj);
  }
D.2317.parts.obj = 0B;
  }


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2014-01-12 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #12 from Dominique d'Humieres dominiq at lps dot ens.fr ---
For the test in comment 9, valgrind gives

==30542== Conditional jump or move depends on uninitialised value(s)
==30542==at 0x10D3C: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==at 0x7FE007B0: ???
==30542==by 0x10DCB: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==at 0x7FE007B6: ???
==30542==by 0x10DCB: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542== 
==30542== Conditional jump or move depends on uninitialised value(s)
==30542==at 0x7FE007F3: ???
==30542==by 0x10DCB: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542== 
==30542== Use of uninitialised value of size 8
==30542==at 0x7FE012B1: ???
==30542==by 0x7FE00879: ???
==30542==by 0x10DCB: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542== 
==30542== Invalid read of size 1
==30542==at 0x7FE012B1: ???
==30542==by 0x7FE00879: ???
==30542==by 0x10DCB: MAIN__ (pr59678.f90:25)
==30542==by 0x10E95: main (pr59678.f90:21)
==30542==  Address 0xe41 is not stack'd, malloc'd or (recently) free'd

I am not sure that the code is valid: allocatables not allocated.


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2014-01-12 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #13 from Dominique d'Humieres dominiq at lps dot ens.fr ---
For the test in comment 11 valgrind gives

==41825== Invalid read of size 4
==41825==at 0x7FE007BF: ???
==41825==by 0x10DAF: MAIN__ (pr59678_1.f90:20)
==41825==by 0x10ED4: main (pr59678_1.f90:21)
==41825==  Address 0x1 is not stack'd, malloc'd or (recently) free'd


[Bug fortran/59678] [F03] Segfault on equalizing variables of a complex derived type

2014-01-12 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59678

--- Comment #14 from janus at gcc dot gnu.org ---
(In reply to janus from comment #11)
 The dump shows that the assignment is translated into:
 
   {
 void * restrict D.2321;
 integer(kind=8) D.2320;
 integer(kind=8) D.2319;
 integer(kind=8) D.2318;
 struct t1 D.2317;
 
 D.2317 = y;
 y = x;
 y.parts = x.parts;
 y.parts.obj = x.parts.obj;

Up to here the dump is fine, but it the next line things start to go wrong:

 if ((void *) x.parts.obj.vec.data != 0B)

We fail to check if obj is allocated.